Changes for page Basic Tiles Integration

Last modified by Ken McWilliams on 2012/03/20 22:49

From version 1.1 Icon
edited by Ken McWilliams
on 2012/03/18 21:55
Change comment: There is no comment for this version
To version Icon 2.1 Icon
edited by Ken McWilliams
on 2012/03/18 23:27
Change comment: There is no comment for this version

Summary

Details

Icon Page properties
Content
... ... @@ -19,7 +19,13 @@
19 19  * Increases the separation beween designers and programmers. There should be more separation between JSPs which aquire and display data and JSPs which act as templates, the later of which the designers are more interested in.
20 20  * Tiles xml provides a souce from which all template definitions can be viewed at once (this is the main strength over JPS includes and will be expanded upon in the next section).
21 21  
22 -== Apache Tiles vs JSP includes ==
22 +== Apache Tiles vs SiteMesh vs JSP includes ==
23 23  
24 -Before I start there is another major player: Sitemesh.
24 +[[SiteMesh>>url:http://www.sitemesh.org/]] and [[Apache Tiles>>url:http://tiles.apache.org/]] differ in how they construct pages. Tiles primarely uses a composition pattern while Sitemesh Uses a decorator pattern for a better discussion of the difference see [[here>>url:http://tiles.apache.org/tutorial/pattern.html]]. To complicate matters and narrow the distance Apache Tiles has added decorator features as well but this is currently beyond the scope of these tutorials.
25 25  
26 +The Decorator pattern is the more powerful of the two but it is also the more conceptually complicated, requires more computational overhead and may not ease the separation between designers and programmers (actually it can nessesitate that designers //are// programmers)... for these reasons I recommend looking at Apache Tiles first. It is a rather simple system which is easy to initially learn, if you find you need more power then look to SiteMesh. It should be noted that you can use both Tiles and SiteMesh in a Struts2 application and if decoration is required then that is the recommended way (By Antonio Petrelli see [[here>>url:http://struts.1045723.n5.nabble.com/Tiles-decoration-filter-and-Struts-2-problem-td3553136.html]]).
27 +
28 +Apache Tiles offers more than JSP includes. The main usage difference is that the tiles.xml file provieds a single source of definition, which defines what resources are brought together to produce a view. JSPs on the other hand mix the resources of the view (the JSP it self) with the content that must be included. What this means, is if a complicated layout has all the commonality factored out both JSPs using includes and JSPs assembled with Tiles, there would as many JSPs using either system however to understand the JSPs using includes you would need to visit each page and then visit each of those pages in turn to see what is being included. It's very much like Rusian Dolls, to know what you are getting you'll need to open each one up. Contrast this with tiles: Each JSP should be terminal and not include any other resources on their own (it is the job of Apache Tiles to insert the resources into the pages as defined in the tiles.xml and marked in the JSPs by Tiles tags). The result is that you should be able to find the resource which needs modification more readily with Tiles. Put another way, Apache Tiles reaches out, gathers all the resources it needs puts them together and spits out the result. It is easy to understand because the definition for everything it needs is defined in one place.
29 +
30 +
31 +The Tiles XML file and Tiles tags do add a little overhead but with any new tool there is a cost of learning. The tags are quite simple and the XML is easy enough to understand that designers can definitly derive benifits from adding the management of the tiles.xml file to their list of responsibilities (it will make their lives easier).