Home Article

Tiles in JavaServer Faces (JSF)

URL: http://www.exadel.com/downloads/jsf/examples/jsf-tiles.war (2.14M)

This short example shows how use JSF together with Tiles. All you have to do is add struts.jar from the Struts1.1 distributive to your classpath. Including struts.jar does not mean that Struts itself is required to use with Tiles. Tiles packages are distributed inside the struts.jar. No other funclionality of the Struts Framework will be involved.

Useful Tips:

  1. This is a snippet from web.xml that makes Tiles enabled:
      <servlet-name>Faces Servlet</servlet-name> 
    Pay attention to the load-on-startup tag. Tiles Servlet should be loaded after the Faces Servlet. It is important.
  2. tiles-defs.xml file is a standard Tiles definitions file. You can use several of them. Use comma separated string to define such files for the definitions-config.
  3. Use flush="false" for the tiles:insert tag is you use it inside the f:view
  4. Use f:subview if you use tiles inside the f:facet. For example:
    <f:facet name="header"> 
      <f:subview id="header"> 
        <tiles:insert definition="page.header" flush="false"/> 
  5. Never include f:view inside another f:view
  6. You cannot forward directly to the tiles, like in the Struts. So, anyway, the faces-config file should contain a pages as a view.
  7. Follow the documentation -http://www.lifl.fr/~dumoulin/tiles/
  8. For Exadel JSF Studio users: The jsf-tiles as a JSF Studio Project is also available for download: http://www.exadel.com/downloads/jsf/examples/jsf-tiles.zip. Unzip it and import into your JSF Studio.

See Also:

Integrating Struts, Tiles, and JavaServer Faces

This article demonstrates how to customize the classes in the Struts-Faces
integration library to make them work with Tiles and JSF

JavaServer Faces and Struts: Competition or Coexistence?

Will Struts and JavaServer Faces coexist in the future?