Struts Tiles JSF MyFaces migration or integration
In a project I had a Struts Tiles based application which should be migrated to JSF. As JSF implementation we had chosen MyFaces.
Struts Tiles is a nice templating solution. You can define a website layout for example a header, footer and and body and place your content in these parts. Here you can find a basic tutorial.
The first information, I came across was outdated. It proposed the use of a TilesServlet to integrate not to migrate Struts Tiles. This was long before Tiles were integrated into Struts. Please be aware that the following Tiles home page is outdated as well.
After further readings, I came across two options
Struts Tiles -> JSF migration
An alternative to Struts Tiles seems to be Facelets. It looks a little bit like Tapestry and could be used as alternative to Struts Tiles. I did not follow these option but you may try it if you like.
Struts Tiles and JSF integration
Integration has the advantage that there is only little rework of Tiles web pages required. Support for Struts Tiles is provided by the MyFaces Tomahawk project.
MyFaces and Struts Tiles integration
The MyFaces project formerly had example applications in the download. I found these examples in the archiv area. They might be a little outdated but at least for the Struts Tiles integration these examples were perfect.
Here is a quick walk through
1) Add the Tiles view handler to your faces-config.xml.
<application><br> <view-handler>org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl</view-handler><br></application>
2) Rename the name of tiles definitons to someName.tiles
<definition name="/searchResults.tiles" extends="myBaseTemplate" ><br> <put name="body" value="/searchResults.jspx" /><br></definition>
3) Migrate your JSPs to JSF.
In template files you frequently have to add the following to insert a tile into the template. flush=false is important,
<f:subview id="body"><br> <tiles:insert attribute="body" flush="false" /><br></f:subview>
Alternatives to JSF and Struts Tiles
I found a number of articles comparing JSF with Tapestry. I would like to invite you to try this framework as well. What I like about Tapestry is that you can create your templates with simple HTML editors.
Some pointers:
http://www.thoughtsabout.net/blog/archives/000052.html
http://sandbox.sourcelabs.com/kosta/web_ui_compare/readme/index.html
http://wiki.osafoundation.org/bin/view/Projects/WebFrameworkComparison
http://www.theserverside.com/tt/articles/article.tss?l=JavaOne_Day4
http://www.theserverside.com/tt/articles/article.tss?l=JSFTapestry
Best Regards
Sebastian Hennebrueder