com.mycompany.jsf.pl
Class ClassViewHandler

java.lang.Object
  extended byjavax.faces.application.ViewHandler
      extended bycom.mycompany.jsf.pl.ClassViewHandler
Direct Known Subclasses:
XMLViewHandler

public class ClassViewHandler
extends javax.faces.application.ViewHandler

This class is a JSF ViewHandler that works with views created by classes implementing the View interface.

Version:
1.0
Author:
Hans Bergsten, Gefion Software

Field Summary
protected  javax.faces.application.ViewHandler origViewHandler
           
private static java.lang.String STATE_VAR
           
private  java.util.Map views
           
 
Fields inherited from class javax.faces.application.ViewHandler
CHARACTER_ENCODING_KEY, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME
 
Constructor Summary
ClassViewHandler(javax.faces.application.ViewHandler origViewHandler)
          Creates an instance and saves a reference to the previously registered ViewHandler.
 
Method Summary
 java.util.Locale calculateLocale(javax.faces.context.FacesContext context)
          Delegates the call to the previously registered ViewHandler.
 java.lang.String calculateRenderKitId(javax.faces.context.FacesContext context)
          Delegates the call to the previously registered ViewHandler.
 javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context, java.lang.String viewId)
          Returns the UIViewRoot for the specified view ID, created by the createViewRoot() method, with the "locale" and "renderKitId" properties initialized.
protected  javax.faces.component.UIViewRoot createViewRoot(javax.faces.context.FacesContext context, java.lang.String viewId)
          Returns the UIViewRoot for the view created by the View instance matching the view ID.
 java.lang.String getActionURL(javax.faces.context.FacesContext context, java.lang.String viewId)
          Delegates the call to the previously registered ViewHandler.
 java.lang.String getResourceURL(javax.faces.context.FacesContext context, java.lang.String path)
          Delegates the call to the previously registered ViewHandler.
protected  void renderResponse(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Recursively renders the provided component and all its children by calling encodeBegin(), encodeChildren() (if the component renders its children) and encodeEnd().
 void renderView(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewToRender)
          Gets the view state to save, if any, and puts a reference to the state in a request scope variable where it can be picked up by the writeState() method, and renders the view represented by the provided UIViewRoot instance by calling renderResponse().
 javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context, java.lang.String viewId)
          Returns the UIViewRoot for the restored view identified by the provided view ID, or null if no state is available.
private  void setupResponseWriter(javax.faces.context.FacesContext context)
          Asks the current RenderKit to create a ResponseWriter around the OutputStream for the response body and sets the Content-Type response header to the MIME type selected by the ResponseWriter from the alternatives listed in the Accept request header.
 void writeState(javax.faces.context.FacesContext context)
          Writes the state captured and saved by the renderView() method to the response with the help of the current StateManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_VAR

private static final java.lang.String STATE_VAR
See Also:
Constant Field Values

origViewHandler

protected javax.faces.application.ViewHandler origViewHandler

views

private java.util.Map views
Constructor Detail

ClassViewHandler

public ClassViewHandler(javax.faces.application.ViewHandler origViewHandler)
Creates an instance and saves a reference to the previously registered ViewHandler.

Method Detail

calculateLocale

public java.util.Locale calculateLocale(javax.faces.context.FacesContext context)
Delegates the call to the previously registered ViewHandler.


calculateRenderKitId

public java.lang.String calculateRenderKitId(javax.faces.context.FacesContext context)
Delegates the call to the previously registered ViewHandler.


getActionURL

public java.lang.String getActionURL(javax.faces.context.FacesContext context,
                                     java.lang.String viewId)
Delegates the call to the previously registered ViewHandler.


getResourceURL

public java.lang.String getResourceURL(javax.faces.context.FacesContext context,
                                       java.lang.String path)
Delegates the call to the previously registered ViewHandler.


createView

public javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context,
                                                   java.lang.String viewId)
Returns the UIViewRoot for the specified view ID, created by the createViewRoot() method, with the "locale" and "renderKitId" properties initialized.


renderView

public void renderView(javax.faces.context.FacesContext context,
                       javax.faces.component.UIViewRoot viewToRender)
                throws java.io.IOException
Gets the view state to save, if any, and puts a reference to the state in a request scope variable where it can be picked up by the writeState() method, and renders the view represented by the provided UIViewRoot instance by calling renderResponse().

Throws:
java.io.IOException

restoreView

public javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context,
                                                    java.lang.String viewId)
Returns the UIViewRoot for the restored view identified by the provided view ID, or null if no state is available.


writeState

public void writeState(javax.faces.context.FacesContext context)
                throws java.io.IOException
Writes the state captured and saved by the renderView() method to the response with the help of the current StateManager.

Throws:
java.io.IOException

createViewRoot

protected javax.faces.component.UIViewRoot createViewRoot(javax.faces.context.FacesContext context,
                                                          java.lang.String viewId)
Returns the UIViewRoot for the view created by the View instance matching the view ID.


renderResponse

protected void renderResponse(javax.faces.context.FacesContext context,
                              javax.faces.component.UIComponent component)
                       throws java.io.IOException
Recursively renders the provided component and all its children by calling encodeBegin(), encodeChildren() (if the component renders its children) and encodeEnd().

Throws:
java.io.IOException

setupResponseWriter

private void setupResponseWriter(javax.faces.context.FacesContext context)
                          throws java.io.IOException
Asks the current RenderKit to create a ResponseWriter around the OutputStream for the response body and sets the Content-Type response header to the MIME type selected by the ResponseWriter from the alternatives listed in the Accept request header.

Throws:
java.io.IOException