org.apache.shale.tiles
Class TilesViewHandler

java.lang.Object
  extended by javax.faces.application.ViewHandler
      extended by org.apache.shale.tiles.TilesViewHandler

public class TilesViewHandler
extends javax.faces.application.ViewHandler

This view handler strips the suffix off of the view ID and looks for a tile whose name matches the resulting string. For example, if the view ID is /tiles/test.jsp, this view handler will look for a tile named /tiles/test. If the tile is found, it is rendered; otherwise, this view handler delegates to the default JSF view handler.

To render a tile, this view handler first locates the tile by name. Then it creates or accesses the Tile Context, and stores the tile's attributes in the context. Finally, it dispatches the request to the tile's layout by calling JSF's ExternalContext.dispatch(). Layouts typically contain <tiles:insert> tags that include dynamic content.

If the request does not reference a tile, this view handler delegates view rendering to the default view handler. That means that URLs like this: http://localhost:8080/example/index.faces will work as expected.

Most of the methods in this class simply delegate to the default view handler, which JSF passes to this view handler's constructor. The only method that has a meaningful implementation is void renderView(FacesContext, UIViewRoot), which renders the current view in accordance with the algorithm discussed above. Note: This Tiles view handler is tied to the standalone version of Tiles, which resides in the Struts sandbox. This view handler will not work with Struts Tiles.


Field Summary
 
Fields inherited from class javax.faces.application.ViewHandler
CHARACTER_ENCODING_KEY, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME
 
Constructor Summary
TilesViewHandler(javax.faces.application.ViewHandler defaultViewHandler)
          Stores the reference to the default view handler for later use.
 
Method Summary
 Locale calculateLocale(javax.faces.context.FacesContext context)
          Pass through to the default view handler.
 String calculateRenderKitId(javax.faces.context.FacesContext context)
          Pass through to the default view handler.
 javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context, String viewId)
          Pass through to the default view handler.
 String getActionURL(javax.faces.context.FacesContext context, String viewId)
          Pass through to the default view handler.
 String getResourceURL(javax.faces.context.FacesContext context, String path)
          Pass through to the default view handler.
 void renderView(javax.faces.context.FacesContext facesContext, javax.faces.component.UIViewRoot viewToRender)
          Render a view according to the algorithm described in this class's description: Based on the view Id of the viewToRender, this method either renders a tile or delegates rendering to the default view handler, which takes care of business as usual.
 javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context, String viewId)
          Pass through to the default view handler.
 void writeState(javax.faces.context.FacesContext context)
          Pass through to the default view handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TilesViewHandler

public TilesViewHandler(javax.faces.application.ViewHandler defaultViewHandler)

Stores the reference to the default view handler for later use.

Parameters:
defaultViewHandler - The default view handler
Method Detail

renderView

public void renderView(javax.faces.context.FacesContext facesContext,
                       javax.faces.component.UIViewRoot viewToRender)
                throws IOException,
                       javax.faces.FacesException

Render a view according to the algorithm described in this class's description: Based on the view Id of the viewToRender, this method either renders a tile or delegates rendering to the default view handler, which takes care of business as usual.

Specified by:
renderView in class javax.faces.application.ViewHandler
Parameters:
facesContext - The faces context object for this request
viewToRender - The view that we're rendering
Throws:
IOException
javax.faces.FacesException

createView

public javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context,
                                                   String viewId)

Pass through to the default view handler.

Specified by:
createView in class javax.faces.application.ViewHandler

calculateLocale

public Locale calculateLocale(javax.faces.context.FacesContext context)

Pass through to the default view handler.

Specified by:
calculateLocale in class javax.faces.application.ViewHandler

calculateRenderKitId

public String calculateRenderKitId(javax.faces.context.FacesContext context)

Pass through to the default view handler.

Specified by:
calculateRenderKitId in class javax.faces.application.ViewHandler

getActionURL

public String getActionURL(javax.faces.context.FacesContext context,
                           String viewId)

Pass through to the default view handler.

Specified by:
getActionURL in class javax.faces.application.ViewHandler

getResourceURL

public String getResourceURL(javax.faces.context.FacesContext context,
                             String path)

Pass through to the default view handler.

Specified by:
getResourceURL in class javax.faces.application.ViewHandler

restoreView

public javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context,
                                                    String viewId)

Pass through to the default view handler.

Specified by:
restoreView in class javax.faces.application.ViewHandler

writeState

public void writeState(javax.faces.context.FacesContext context)
                throws IOException

Pass through to the default view handler.

Specified by:
writeState in class javax.faces.application.ViewHandler
Throws:
IOException


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.