| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.faces.application.ViewHandler
public abstract class ViewHandler
ViewHandler is the pluggablity mechanism for allowing implementations of or applications using the JavaServer Faces specification to provide their own handling of the activities in the Render Response and Restore View phases of the request processing lifecycle. This allows for implementations to support different response generation technologies, as well as alternative strategies for saving and restoring the state of each view.
Please see StateManager for information on how the
 ViewHandler interacts the StateManager. 
| Field Summary | |
|---|---|
| static java.lang.String | CHARACTER_ENCODING_KEYThe key, in the session's attribute set, under which the response character encoding may be stored and retrieved. | 
| static java.lang.String | DEFAULT_SUFFIXThe value to use for the default extension if the webapp is using url extension mapping. | 
| static java.lang.String | DEFAULT_SUFFIX_PARAM_NAMEAllow the web application to define an alternate suffix for pages containing JSF content. | 
| Constructor Summary | |
|---|---|
| ViewHandler() | |
| Method Summary | |
|---|---|
|  java.lang.String | calculateCharacterEncoding(FacesContext context)Returns the correct character encoding to be used for this request. | 
| abstract  java.util.Locale | calculateLocale(FacesContext context)Returns an appropriate Localeto use for this and
 subsequent requests for the current client. | 
| abstract  java.lang.String | calculateRenderKitId(FacesContext context)Return an appropriate renderKitIdfor this and
 subsequent requests from the current client. | 
| abstract  UIViewRoot | createView(FacesContext context,
           java.lang.String viewId)Create and return a new UIViewRootinstance
 initialized with information from the argumentFacesContextandviewId. | 
| abstract  java.lang.String | getActionURL(FacesContext context,
             java.lang.String viewId)Return a URL suitable for rendering (after optional encoding performed by the encodeActionURL()method ofExternalContext) that selects the specified view identifier. | 
| abstract  java.lang.String | getResourceURL(FacesContext context,
               java.lang.String path)Return a URL suitable for rendering (after optional encoding perfomed by the encodeResourceURL()method ofExternalContext) that selects the specifed web application
 resource. | 
|  void | initView(FacesContext context)Initialize the view for the request processing lifecycle. | 
| abstract  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. | 
| abstract  UIViewRoot | restoreView(FacesContext context,
            java.lang.String viewId)Perform whatever actions are required to restore the view associated with the specified FacesContextandviewId. | 
| abstract  void | writeState(FacesContext context)Take any appropriate action to either immediately write out the current state information (by calling StateManager.writeState(javax.faces.context.FacesContext, java.lang.Object), or noting where state information
 should later be written. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final java.lang.String CHARACTER_ENCODING_KEY
The key, in the session's attribute set, under which the response character encoding may be stored and retrieved.
public static final java.lang.String DEFAULT_SUFFIX_PARAM_NAME
Allow the web application to define an alternate suffix for
 pages containing JSF content.  If this init parameter is not
 specified, the default value is taken from the value of the
 constant DEFAULT_SUFFIX.
public static final java.lang.String DEFAULT_SUFFIX
The value to use for the default extension if the webapp is using url extension mapping.
| Constructor Detail | 
|---|
public ViewHandler()
| Method Detail | 
|---|
public abstract java.util.Locale calculateLocale(FacesContext context)
Returns an appropriate Locale to use for this and
 subsequent requests for the current client.
context - FacesContext for the current request
java.lang.NullPointerException - if context is 
  nullpublic java.lang.String calculateCharacterEncoding(FacesContext context)
Returns the correct character encoding to be used for this request.
The following algorithm is employed.
Examine the Content-Type request header.  If it has 
 a charset parameter, extract it and return that as the 
 encoding.
If no charset parameter was found, check for the 
 existence of a session by calling ExternalContext.getSession(boolean) 
 passing false as the argument.  If that method returns 
 true, get the session Map by calling 
 ExternalContext.getSessionMap() and look for a value under the 
 key given by the value of the symbolic constant 
 CHARACTER_ENCODING_KEY.
 If present, return the value, converted to String.
Otherwise, return null
public abstract java.lang.String calculateRenderKitId(FacesContext context)
Return an appropriate renderKitId for this and
 subsequent requests from the current client.  It is an error for
 this method to return null.
The default return value is RenderKitFactory.HTML_BASIC_RENDER_KIT.
context - FacesContext for the current request
java.lang.NullPointerException - if context is 
  null
public abstract 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 calculateLocale(javax.faces.context.FacesContext) and
 calculateRenderKitId(javax.faces.context.FacesContext), and store the results as the
 values of the  locale and renderKitId,
 proeprties, respectively, of the newly created
 UIViewRoot.
java.lang.NullPointerException - if context
  is null
public abstract 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.
context - FacesContext for this requestviewId - View identifier of the desired view
java.lang.IllegalArgumentException - if viewId is not
  valid for this ViewHandler.
java.lang.NullPointerException - if context or
  viewId is null.
public abstract 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.
context - FacesContext for the current requestpath - Resource path to convert to a URL
java.lang.IllegalArgumentException - if viewId is not
  valid for this ViewHandler.
java.lang.NullPointerException - if context or
  path is null.
public void initView(FacesContext context)
              throws FacesException
Initialize the view for the request processing lifecycle.
This method must be called at the beginning of the Restore View Phase of the Request Processing Lifecycle. It is responsible for performing any per-request initialization necessary to the operation of the lifycecle.
The default implementation calls calculateCharacterEncoding(javax.faces.context.FacesContext)
 and passes the result, if non-null into the
 ExternalContext.setRequestCharacterEncoding(java.lang.String) method.
FacesException - if a problem occurs setting the encoding,
 such as the UnsupportedEncodingException thrown 
 by the underlying Servlet or Portlet technology when the encoding is not
 supported.
public abstract void renderView(FacesContext context,
                                UIViewRoot viewToRender)
                         throws java.io.IOException,
                                FacesException
Perform whatever actions are required to render the response
 view to the response object associated with the
 current FacesContext.
context - FacesContext for the current requestviewToRender - the view to render
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if context or
 viewToRender is null
FacesException - if a servlet error occurs
public abstract 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.
context - FacesContext for the current requestviewId - the view identifier for the current request
java.lang.NullPointerException - if context
  is null
FacesException - if a servlet error occurs
public abstract void writeState(FacesContext context)
                         throws java.io.IOException
Take any appropriate action to either immediately
 write out the current state information (by calling
 StateManager.writeState(javax.faces.context.FacesContext, java.lang.Object), or noting where state information
 should later be written.
context - FacesContext for the current request
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if context
  is null| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||