2Tiles IntroductionTiles is a framework for the development user interfaceTiles 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
3Tiles IntroductionFor example, if you have to develop a web site having more that 500 page of static content and many dynamically generated pages. The layout of the web site often changes according to the business requirement. In this case you can use the Tiles framework to design the template for the web site and use this template to populate the contents. In future if there is any requirement of site layout change then you have to change the layout in one page. This will change the layout of you whole web site.
4Tiles1 and Tiles2Tiles has been designed to use with the Struts FrameworkTiles can be used with or without Struts.Tiles which has been design to use with out Struts is called as Tiles2
5Steps To Create Tiles Application Tiles is very useful framework for the development of web applications. Here are the steps necessary for adding Tiles to your Struts applicationAdd the Tiles Tag Library Descriptor (TLD) file to the web.xml.Create layout JSPs.Develop the web pages using layouts.Repackage, run and test application.
6Add the Tiles TLD to web.xml file <taglib> <taglib-uri>/tags/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/struts-t iles.tld</taglib-location> </taglib>
7Create layout JSPs.Our web application layout is divided into four parts: To Banner, Left Navigation Bar, Content Area and Bottom of the page for copy right information. Here is the code for out template (template.jsp):
10Repackage, run and test application <li> <html:link page="/tiles/example.jsp">Tiles Example</html:link> <br> Example of creating first tile application. </li>
11Steps to Use the tiles-defs.xml Add the following code in the struts.xml, This enables the TilesPlugin to use the /WEB-INF/tiles-defs.xml file.<plug-in className="org.apache.struts.tiles.TilesPlugin" > <!-- Path to XML definition file --> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> <!-- Set Module-awareness to true --> <set-property property="moduleAware" value="true" /> </plug-in>