Académique Documents
Professionnel Documents
Culture Documents
Tiles Introduction
Tiles
is a framework for the development user interface Tiles is enables the developers to develop the web applications by assembling the reusable tiles (jsp, html, etc..) Tiles uses the concept of reuse and enables the developers to define a template for the web site and then use this layout to populate the content of the web site
Tiles Introduction
For example, if you have to develop a web site having more that !! page of static content and many dynamically generated pages. The layout of the web site often changes according to the business re"uirement. #n this case you can use the Tiles framework to design the template for the web site and use this template to populate the contents. #n future if there is any re"uirement of site layout change then you have to change the layout in one page. This will change the layout of you whole web site.
has been designed to use with the $truts Framework Tiles can be used with or without $truts. Tiles which has been design to use with out $truts is called as Tiles%
Tiles is very useful framework for the development of web applications. &ere are the steps necessary for adding Tiles to your $truts application
' ' ' '
(dd the Tiles Tag )ibrary *escriptor (T)*) file to the web.xml. +reate layout ,$-s. *evelop the web pages using layouts. .epackage, run and test application.
web application layout is divided into four parts8 To 5anner, )eft 6avigation 5ar, +ontent (rea and 5ottom of the page for copy right information. &ere is the code for out template (template."sp)8
template.jsp
/9: page language;<java< 90 #$% ta&lib uri'()*+,-I./)struts-tiles.tld( prefix'(tiles( $0 /html0 /head0 /title0#tiles1&etAsStrin& name'(title( i&nore'(true()0/2title0 /2head0 /body0 /table border;<=< cellpadding;<!< cellspacing;<!< width;<=!!9< bordercolor;<>!!!!!!< bgcolor;<>4?F*F4<0 /tr0 /td width;<=!!9< colspan;<%< valign;<top<0#tiles1insert attribute'(header()0/2td0 /2tr0 /tr0 /td width;<%@9<0#tiles1insert attribute'(menu()0/2td0 /td width;<??9< valign;<top< valign;<top<0#tiles1insert attribute'(body()0/2td0 /2tr0 /tr0 /td width;<=!!9< colspan;<%< valign;<top<0#tiles1insert attribute'(bottom()0/2td0 /2tr0 /2table0 /2body0 /2html0
example.jsp
/9: page language;<java< 90 /9: taglib uri;<23451#6F2struts1tiles.tld< prefix;<tiles< 90 /tiles8insert page;<2tiles2template.jsp< flush;<true<0 /tiles8put name;<title< type;<string< value;<3elcome< 20 /tiles8put name;<header< value;<2tiles2top.jsp< 20 /tiles8put name;<menu< value;<2tiles2left.jsp< 20 /tiles8put name;<body< value;<2tiles2content.jsp< 20 /tiles8put name;<bottom< value;<2tiles2bottom.jsp< 20 /2tiles8insert0
/html8link page;<2tiles2example.jsp<0Tiles 4xample/2html8link0 /br0 4xample of creating first tile application. /2li0
(dd the following code in the struts.xml, This enables the Tiles-lugin to use the 23451#6F2tiles1defs.xml file. /plug1in class6ame;<org.apache.struts.tiles.Tiles-lugin< 0 /A11 -ath to BC) definition file 110 /set1property property;<definitions1config< value;<23451 #6F2tiles1defs.xml< 20 /A11 $et Codule1awareness to true 110 /set1property property;<module(ware< value;<true< 20 /2plug1in0
/Dxml version;<=.!< encoding;<#$71EE F1=< D0 /A*7+TG-4 tiles1definitions -H5)#+ <122(pache $oftware Foundation22*T* Tiles +onfiguration =.=2246< <http822jakarta.apache.org2struts2dtds2tiles1configI=I=.dtd<0 /tiles1definitions0 /definition name;<Tiles.4xample< page;<2tiles2template.jsp<0 /put name;<title< type;<string< value;<3elcome< 20 /put name;<header< value;<2tiles2top.jsp< 20 /put name;<menu< value;<2tiles2left.jsp< 20 /put name;<body< value;<2tiles2content.jsp< 20 /put name;<bottom< value;<2tiles2bottom.jsp< 20 /2definition0
/definition name;<JKG7H.I*4F#6#T#76I&4.4L<0 /2definition0
/2tiles1definitions0
code8
/action
path;<2Tiles24xample< forward;<Tiles.4xample<20
/html8link page;<2Tiles24xample.do<0Hsing tiles1defs.xml/2html8link0 /br0 4xample shows you how to use tiles1defs.xml file. /2li0
http822www.laliluna.de2tutorial2first1tiles2firstIstrutsI
ml
Thank Gou