I wonder if the Tiles framework its really useful or not... I have been some hours trying to determine if its useful for a real production service to be developed in J2SE , but in comparison with the common "jsp:includes" I can't find a real advantage, specially since Struts is not used.
If anybody can figure any advantage of this way of arrange JSP layouts, please let me know! :-)
Well, using JSP includes does not eliminate the amount of jsp pages that you need to create. Tiles is configurable so that it can plug in the appropriate jsp file into one template so that the look and feel is the same for every jsp that references that template in the tiles-defs.xml file. This gives the whole app the same look and feel and all the developer needs to deal with is page content.
Tiles is extremely useful even if you are not using struts.
No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
It also means that you don't have to worry about passing and/or encoding a parameter indicating what content should be in the page. Consider a site that has a header, footer, and content -- each of which can be changed. Which would you rather link to:
Things for Option 'A' get even worse when the page contains HTML forms or items that require their own parameters.
Ugly URLs are the mother of invention -- Hence why Tiles and JSF were born.
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
Joined: Dec 29, 2004
This gives the whole app the same look and feel and all the developer needs to deal with is page content
But if I have a header.jsp and a footer.jsp and then pages like page1.jsp, page2.jsp with the same html structure (copy-paste, maybe from a simple html file that could be considered a layout...), and in these pages I insert at the beginning the header.jsp and at the end footer.jsp with includes, I have the same look and feel also.
With Tiles I have the same but the developer far from deal only with page content needs to create the layout, and with Struts she needs to deal with the xml definitions, create a nonoperational Action and deal with the configuration of Struts. More complex, more or less same results.
Consider a site that has a header, footer, and content -- each of which can be changed
In this case I think we could have in page1.jsp an if condition. If the parameter we receive is header=header1, we will put the include with header1. If the parameter is header2, we will put the include with header2. And neither these parameters nor others we could be getting from a form need to appear in the URL if we use POST
Simpler solutions, almost same results. Yes, Tiles could be more nice to see but I can't see real advantages in comparison with the added complexity. Maybe if you need to change everything in an application after all the development... but even then you could change the includes with no difficulty... and in Tiles maybe you will need to change the definitions and the layouts and the struts configuration, I suppose it's not so easy.
I really WANT to find a good advantage to introduce Tiles in the project (must be useful, if people have developed it) but I am not able to find any!
Joined: Nov 01, 2002
Valid points. Do it how you feel comfortable doing it. I once felt the same way but after I started using struts and tiles, I found it extremely easy to develop, manage, and maintain my sites that use tiles. This is just one person's opinion though.
You can create composite view from many smaller views using JSP includes. In such case, you have to use include in each and every jsp page as per your layput and such layout is repeated in each page. But what will you do when your layout itself changes? You have to change the position of includes in each and every page. Besause Jsp Include is not for defining a layout. It simply allows content from one page to be used in another. Where is the generic template?
Precisely this is where Tiles comes to our rescue.
The following is the official definitation of tiles: The Tiles Framework is an advanced version of <jsp:include/> that comes bundled with the Struts web application framework. Its purpose is to reduce the duplication between jsp pages as well as make layouts flexible and easy to maintain. It integrates with Struts using the concept of named views or definitions.
Ofcourse, it is true that we don't have to use struts in order to use tiles features.
Do not waste your precious time in trying to determine if its useful for a real production service. It is definitely useful otherwise it would not have got the importance that it has got. Even Microsoft is providing a feature similar to Tiles in the upcoming version of ASP.NET.
Joined: Dec 29, 2004
Thank you for your reply!
I spent this time because I wanted to know if it could be useful for this project that is starting now!
Joined: Nov 01, 2002
venu's post is true to point. This is what I've been trying to say all along. If you feel that this isn't the right time to implement tiles into a project then so be it. I can relate to that. However, I strongly encourage you to investigate Tiles in more detail for future projects. I promise you it is not a waste of time.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com