Jakarta Struts' development team is looking over some problems with memory hogging using tiles. I'm new to tiles and think the concept is long overdue. I hate rewriting html code! I'm wondering if tiles will really catch on. It seems that Java already has so many APIs and whatnot that people are getting fed up with the complexity. I know that there are Perlmongers out there that want to see Java on the client side disappear, but what [honestly] are the chances of seeing tiles commonly listed as a requirement job postings in the next few years? (I'm thinking Struts and tiles together will really make a move within 6 months of the final Struts 1.1 release.) Also, if anyone knows of a good book or website that covers tiles, please post them!
Originally posted by Marc Peabody: Jakarta Struts' development team is looking over some problems with memory hogging using tiles. I'm new to tiles and think the concept is long overdue. I hate rewriting html code!
Me too. So I came up with a way to cheat.
1) Create an action that all it does is forward your user... here's my execute() implementation:
2) Make this action your default action for struts. In your struts config: <action path="tileForward" type="my.struts.TilesAutoForwardAction" unknown="true"> <forward name="404" path="/404.html" /> <forward name="baseForward" path="/tilesContent.jsp" contextRelative="true" /> </action> 3) Create tilesContent.jsp. All it does is include a tiles definition...
4) Create a 404.html for when pages aren't found 5) configure your tiles-defs.xml definitions as usual. 6) Configure your action servlet to respond to all pages of *.do (you probably did this anyway) 7) Make all forwards/links to pages with *.do as an end. To link to a tile definition, i.e. if you have a tile named "faqs" that extends your base layout definition, link to faqs.do Personally I would advise setting a second extension (I use *.dhtml) for your action to respond to. That way you can tell the difference between a link to a tiles definition and an action. Anyway, what this gains you is that you don't have to define 19,786 jsp's that all you do is a tiles:insert for a definition.
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.