This short downloadable example project demonstrates how you can use JSF with Tiles. This is the URL:
http://webdownload.exadel.com/getfiles/jsf/examples/jsf-tiles.war (2.14M)
Then, all you have to do is add the struts.jar file from the Struts 1.1 distribution to your classpath. Including struts.jar does not mean that Struts itself is required to use JSF with Tiles. It's just that the Tiles packages are distributed inside the struts.jar file. No other functionality of the Struts Framework is involved.
Some Useful Tips
1. Here is the snippet from the web.xml file that enables Tiles:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>TilesServet</servlet-name>
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
Pay attention to the load-on-startup tag. The Tiles Servlet should be loaded after the Faces Servlet. This is important!
2. tiles-defs.xml is the standard name for a Tiles definitions file. However, you can call it anything you want and you can use more than one file. Use a comma-separated string to define such files for the definitions-config parameter in the web.xml file.
3. Use flush="false" for the tiles:insert tag is you use it inside an f:view element (between opening and closing f:view tags).
4. Use f:subview if you use tiles inside an f:facet element. For example:
<f:facet name="header">
<f:subview id="header">
<tiles:insert definition="page.header" flush="false"/>
</f:subview>
</f:facet>
5. Never include an f:view element inside another f:view element.
6. You cannot forward directly to the tiles, like in Struts. So, the JSF faces-config file should reference the pages using tiles as views.
7. Follow this online documentation: http://www.lifl.fr/~dumoulin/tiles/
8. For Exadel JSF Studio users, the jsf-tiles example is also available as a Exadel Studio project: http://webdownload.exadel.com/getfiles/jsf/examples/jsf-tiles.zip. Unzip it and import (File/Import/JSF Project) it into your Exadel Studio workspace.
Using Tiles in JSF Applications
Labels: JSF, TILES Framework
Subscribe to:
Post Comments (Atom)
1 comments:
Thanks. Working well with Myfaces 1.1.
I am facing an issue with Myfaces 1.2 and Struts Tiles. The JSF components are not rendered and results in a blank page. Are these two not compatible or does the configuration have to be changed to support myfaces 1.2.
Post a Comment