JSF-Spring

de.mindmatters.faces.application
Class FaceletViewBuilder

java.lang.Object
  extended by javax.faces.application.ViewHandler
      extended by de.mindmatters.faces.application.ViewBuilder
          extended by de.mindmatters.faces.application.FaceletViewBuilder

public final class FaceletViewBuilder
extends ViewBuilder

ViewBuilder implementation based upon jsf-facelets. Facelets is able to restore the structure of a view without any state representing the tree structure.

Configure this resolver in your faces-config.xml file as follows:

            <application>
            ...
              <view-handler>de.mindmatters.faces.application.FaceletViewBuilder</view-handler>
            </application>
 

Author:
Andreas Kuhrwahl
See Also:
ViewBuilder, ViewBuilder.buildView(FacesContext, String), FaceletViewHandler

Field Summary
 
Fields inherited from class javax.faces.application.ViewHandler
CHARACTER_ENCODING_KEY, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME
 
Constructor Summary
FaceletViewBuilder(ViewHandler delegate)
          Constructor that takes the original ViewHandler.
 
Method Summary
 UIViewRoot buildView(FacesContext context, java.lang.String viewId)
          Perform whatever actions are required to build the view associated with the specified FacesContext and viewId.
 java.util.Locale calculateLocale(FacesContext context)
          

Returns an appropriate Locale to use for this and subsequent requests for the current client.

 java.lang.String calculateRenderKitId(FacesContext context)
          

Return an appropriate renderKitId for this and subsequent requests from the current client.

 UIViewRoot createView(FacesContext context, java.lang.String viewId)
          

Create and return a new UIViewRoot instance initialized with information from the argument FacesContext and viewId.

 java.lang.String getActionURL(FacesContext context, java.lang.String viewId)
          

Return a URL suitable for rendering (after optional encoding performed by the encodeActionURL() method of ExternalContext) that selects the specified view identifier.

 java.lang.String getResourceURL(FacesContext context, java.lang.String path)
          

Return a URL suitable for rendering (after optional encoding perfomed by the encodeResourceURL() method of ExternalContext) that selects the specifed web application resource.

 void renderView(FacesContext context, UIViewRoot viewToRender)
          

Perform whatever actions are required to render the response view to the response object associated with the current FacesContext.

 UIViewRoot restoreView(FacesContext context, java.lang.String viewId)
          

Perform whatever actions are required to restore the view associated with the specified FacesContext and viewId.

protected  void writeStateInClient(FacesContext context)
          Writes the state of a view into the response.
 
Methods inherited from class de.mindmatters.faces.application.ViewBuilder
markForTransientState, unmarkTransientState, writeState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FaceletViewBuilder

public FaceletViewBuilder(ViewHandler delegate)
Constructor that takes the original ViewHandler.

Parameters:
delegate - the original ViewHandler
Method Detail

buildView

public UIViewRoot buildView(FacesContext context,
                            java.lang.String viewId)
Perform whatever actions are required to build the view associated with the specified FacesContext and viewId. Building a view means to restore the component tree structure of a view without the need of a serialized state representing the structure.

Specified by:
buildView in class ViewBuilder
Parameters:
context - FacesContext for the current request
viewId - the view identifier for the current request
Returns:
Built UIViewRoot representing the view

writeStateInClient

protected void writeStateInClient(FacesContext context)
                           throws java.io.IOException
Writes the state of a view into the response. Usually this is done by calling StateManager.writeState(javax.faces.context.FacesContext, javax.faces.application.StateManager.SerializedView)

Specified by:
writeStateInClient in class ViewBuilder
Parameters:
context - FacesContext for the current request
Throws:
java.io.IOException - if an input/output error occurs
See Also:
ViewHandler.writeState(FacesContext)

calculateLocale

public java.util.Locale calculateLocale(FacesContext context)

Returns an appropriate Locale to use for this and subsequent requests for the current client.

Specified by:
calculateLocale in class ViewHandler
Parameters:
context - FacesContext for the current request

calculateRenderKitId

public java.lang.String calculateRenderKitId(FacesContext context)

Return an appropriate renderKitId for this and subsequent requests from the current client.

The default return value is RenderKitFactory.HTML_BASIC_RENDER_KIT.

Specified by:
calculateRenderKitId in class ViewHandler
Parameters:
context - FacesContext for the current request

createView

public UIViewRoot createView(FacesContext context,
                             java.lang.String viewId)

Create and return a new UIViewRoot instance initialized with information from the argument FacesContext and viewId.

If there is an existing ViewRoot available on the FacesContext, this method must copy its locale and renderKitId to this new view root. If not, this method must call ViewHandler.calculateLocale(javax.faces.context.FacesContext) and ViewHandler.calculateRenderKitId(javax.faces.context.FacesContext), and store the results as the values of the locale and renderKitId, proeprties, respectively, of the newly created UIViewRoot.

Specified by:
createView in class ViewHandler

getActionURL

public java.lang.String getActionURL(FacesContext context,
                                     java.lang.String viewId)

Return a URL suitable for rendering (after optional encoding performed by the encodeActionURL() method of ExternalContext) that selects the specified view identifier.

Specified by:
getActionURL in class ViewHandler
Parameters:
context - FacesContext for this request
viewId - View identifier of the desired view

getResourceURL

public java.lang.String getResourceURL(FacesContext context,
                                       java.lang.String path)

Return a URL suitable for rendering (after optional encoding perfomed by the encodeResourceURL() method of ExternalContext) that selects the specifed web application resource. If the specified path starts with a slash, it must be treated as context relative; otherwise, it must be treated as relative to the action URL of the current view.

Specified by:
getResourceURL in class ViewHandler
Parameters:
context - FacesContext for the current request
path - Resource path to convert to a URL

renderView

public void renderView(FacesContext context,
                       UIViewRoot viewToRender)
                throws java.io.IOException

Perform whatever actions are required to render the response view to the response object associated with the current FacesContext.

Specified by:
renderView in class ViewHandler
Parameters:
context - FacesContext for the current request
viewToRender - the view to render
Throws:
java.io.IOException - if an input/output error occurs

restoreView

public UIViewRoot restoreView(FacesContext context,
                              java.lang.String viewId)

Perform whatever actions are required to restore the view associated with the specified FacesContext and viewId. It may delegate to the restoreView of the associated StateManager to do the actual work of restoring the view. If there is no available state for the specified viewId, return null.

Specified by:
restoreView in class ViewHandler
Parameters:
context - FacesContext for the current request
viewId - the view identifier for the current request

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG