A new TSS article, by Patrick Peak, shows you how to handle page layout, and create a well-organized, maintainable, Struts-based application using the Tiles Framework. Tiles 101 looks at how to create a standard layout using tiles; In Tiles 201 you will use Tiles Controllers to improve the overall architecture of your application. Examples from an online Penguin Store sample app are provided.
Read Tiles 101/201
by Patrick Peak
Nice intro to Tiles, I hope this will get more people interested in using Tiles. I also like how you presented the Tiles Controller concept. There are many Tiles users that do not take advantage of this (because they're not familiar with it). Often I pose a question to the Struts mailing list and people reply back how I should use actions to preload the values for a form, which is much better done with a Tiles controller.
For more information on Tiles, I strongly recommend Struts in Action.
Yes, Tiles are one of the most useful things in Struts. By, the way you can use templates even without the framework: www.servletsuite.com/servlets/template.htm
FYI, Tiles can also be used independently without Struts, see the PDF available at Cedric's site for details.
I personally find the approach used in the ServletSuite template tags much better than the one used by Tiles. I mean, why go to the trouble of using an XML file if you can achieve the same results by just using a few custom JSP tags in your JSP pages.
Tiles is a dead end. Anyone who want to argue this should take a good look at the sources. Now, I'm being told that <jsp:include /> has to be replaced with all this chain of calls?! Yeah, try getting to the bottom of the <tiles:insert /> to see what I mean. I think that the approach "let's have seven layers of indirection in case we need the solution to 99% of problems" is wrong. To integrate workflow and security and the other dosen concerns into a generic framework is just wrong.
I'll try looking sideways. Aspect-oriented, will that be the right buzzword?
If Tiles is a dead end, what road are you currently taking? I see Tiles as the best approach that's currently available. It's not perfect but it's the best we've got at this time.
The idea of scriptlet riddance was taken too far, IMO. Scriptlets are fast to write, quick to debug and easy to iunderstand. After the code got stabilized, migrate it into custom tag. This way it is lean and mean, you get only what you need by least means possible.
We hope to use Tiles and a bunch of the newer Struts features if Struts would ever become a 1.1 release. We won't use non-released code in our applications. Struts 1.1 has been beta for over a year.
Some day, if it ever becomes 1.1, we'd love to use these new features.
Been using Struts 1.1 beta for ages now and can happly say that product is completely stable enough to consider using right now.
We've built a number of large scale applications using tiles and some of the newer features of 1.1 without any problems whatsoever.
I'd wouldn't wait for the final release. Start using it now.
cheers and many thanks to Jakarta,
If the people that write Struts don't think it's good enough for production, why should I use it in production? It has been a year (or so) since 1.0 was released, so it could be quite a while before 1.1 is a production release. That means I can't use it for development either. I can play with it, but can't use it for real work.
If it's so good, it should be a production release. Until the authors of Struts release it, I have to assume it can't be used in production.
I see your point. On one hand, it's completely stable and works great. On the other the development team isn't motivated by commercial reasons to increase version numbers frequently. If Struts was made by Borland no doubt it'd be at version 5 by now. really Struts could have been 2.0 about 6 months ago, would that change the quality? It's just a name.
Liferay Portal (open source enterprise portal solution, www.liferay.com) recently moved from a pure Struts impl to a Struts+Tiles impl. The move itself took about 2 days, but the benefits are amazing. We lowered the number of lines of repetitive code (JSPs) by about 20%, and now we can create entirely different layouts for the portal by changing 2-3 key files.
You can check out a demo for the portal at my.liferay.com (it's an app that is very similar to the my yahoo and is geared for intranets, provides web e-mail, message boards, calendar, wiki, and other portlets as well).
1. Tiles is one possible way. Perhaps, component-driven web frameworks like Tapestry and Apple WebObjects, give another view, though not everyone accepts it (the same as with tiles :)
2. I read the Tiles author's PDFs several month ago. Though, it is not stated in the article under discussion, the PDF doesn't dictate using controllers in place of actions. It generalises the approach and says they are quite equivalent, except tiles has this ComponentContext. With actions you just return null if you do not want anything to be displayed, return en error forward or success one. It could be something like <put name="penguinOfTheDay" value="/action/pod" />. And what is done with ComponentContext can be modeled in a user state in the model (depends on the app).
3. XML definitions are really cool. If you didn't get it yet, invest some time in it, and it will pay you back. It's all about OO principles - inheritance, where you can override, extend a tile, etc. (no polymorphism, sorry ;)
4. Tiles didn't solve action chaining problems for me. Creating a fatter action/controller is not always a solution (though, the approach in the article recommends exactly this). Consider the case, when you are requesting the data to display in the table, and the same data on the same page is used to chart an image - quite tricky.
In general, I was very pleased with tiles. Right now I'm finishing quite a long-term project that used it, and it was really a pleasure (and extremely easy!) to add/modify/remove dynamic page content after setting everything up. It's like with J2EE - it's an awful lot of info at first, it starts to work only after some up-front work.
If you are not convinced - I recommend you read the PDFs I mentioned above.
this is my first posting on this group...
I am trying to develop a jsp that will be containing data that comes from multiple jsps
the "jsps" to be selected has to be decided at run time...
i have thought of one approach of using tiles and struts ...and change the tile content jsp dynamically ...
but i dont know whether this is the only and best approach...
please give me suggestions for the same...
waiting eagerly for replies
priyankpatwa at yahoo dot com
Is it possible to build component framework for WEB on the basis of tiles?
ControllerClass may be used to make message-dispatching in components.
We are to start a project which has a choice of using WebLogic portal server of Struts/tiles. But there are very limited sources to compare these two exists. Has anyone undergone the both technologies. What do you think is the better solution? Any help is greatly appreciated.
I have done the same thing given in the below link.http://www.theserverside.com/articles/article.tss?l=Tiles101
i created a tiles definition like
<definition name="@dviewPDS" extends="basic.layout">
and then action mapping of struts-config.xml goes like this
<action path="/ViewPDS" type="com.xx.actions.ViewPDs">
<forward name="success" path="@dviewPDS"/>
when i run the application it getting error like "Error 404 File not found:/@dviewPDS"