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. An implementation of this class must be thread-safe.
Please see StateManager for information on how the ViewHandler interacts the
StateManager.
Version 2 of the specification formally introduced the concept of View Declaration
Language. A View Declaration Language (VDL) is a syntax used to declare user interfaces
comprised of instances of JSF UIComponents. Any of the responsibilities of the
ViewHandler that specifically deal with the VDL sub-system are now the domain of the
VDL implementation. These responsibilities are defined on the ViewDeclarationLanguage
class. The ViewHandler provides getViewDeclarationLanguage as a convenience
method to access the VDL implementation given a viewId.
| Modifier and Type | Field and Description |
|---|---|
| public static final 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 String | DEFAULT_FACELETS_SUFFIX
The value to use for the default extension for Facelet based XHTML pages if the webapp is using url extension mapping. |
| public static final String | DEFAULT_SUFFIX
The value to use for the default extension if the webapp is using url extension mapping. |
| public static final String | DEFAULT_SUFFIX_PARAM_NAME
Allow the web application to define a list of alternate suffixes for pages containing JSF content. |
| public static final String | DISABLE_FACELET_JSF_VIEWHANDLER_PARAM_NAME
If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the default ViewHandler must behave as specified in the latest 1.2 version of this specification. |
| public static final String | FACELETS_BUFFER_SIZE_PARAM_NAME
The buffer size to set on the response when the ResponseWriter is generated. |
| public static final String | FACELETS_DECORATORS_PARAM_NAME
A semicolon (;) delimitted list of class names of type javax.faces.view.facelets.TagDecorator, with a no-argument constructor. |
| public static final String | FACELETS_LIBRARIES_PARAM_NAME
If this param is set, the runtime must interpret it as a semicolon (;) separated list of paths, starting with "/" (without the quotes). |
| public static final String | FACELETS_REFRESH_PERIOD_PARAM_NAME
When a page is requested, what interval in seconds should the compiler check for changes. |
| public static final String | FACELETS_SKIP_COMMENTS_PARAM_NAME
If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the runtime must ensure that any XML comments in the Facelets source page are not delivered to the client. |
| public static final String | FACELETS_SUFFIX_PARAM_NAME
Allow the web application to define an alternate suffix for Facelet based XHTML pages containing JSF content. |
| public static final String | FACELETS_VIEW_MAPPINGS_PARAM_NAME
Allow the web application to define a semicolon (;) separated list of strings that is used to forcibly declare that certain pages in the application must be interpreted as using Facelets, regardless of their extension. |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addProtectedView(String
the url-pattern to add. urlPattern)
Add the argument |
| public String | Returns: the character encoding, ornullthe Faces context. context)Returns the correct character encoding to be used for this request. |
| public abstract Locale | Returns: the locale.FacesContext for the current request
Returns an appropriate |
| public abstract String | Returns: the render kit id.FacesContext for the current request
Return an appropriate |
| public abstract UIViewRoot | Returns: the viewroot.the Faces context. context, String the view id. viewId)
Create and return a new |
| public String | Returns: the derived logical view id.the context, String FacesContext for this requestthe requestViewId)viewId to derive,Derive and return the viewId from the current request, or the argument input by following the algorithm defined in specification section JSF.7.6.2. |
| public String | Returns: the derived view id.the context, String FacesContext for this requestthe requestViewId)viewId to derive,Derive and return the viewId from the current request, or the argument input by following the algorithm defined in specification section JSF.7.6.2. |
| public abstract String | Returns: the action url.FacesContext for this requestView identifier of the desired view viewId)
If the value returned from this method is used as
the |
| public String | Returns: the bookmarkable URL.The FacesContext processing this request context, String The view identifier of the target page viewId, Map<String, List<String>> A mapping of parameter names to one or more values parameters, boolean A flag indicating whether view parameters should be encoded into
this URL includeViewParams)Return a JSF action URL derived from the viewId argument that is suitable to be used as the target of a link in a JSF response. |
| public Set | Returns: the unmodifiable set of protected views.
Return an unmodifiable |
| public String | Returns: the redirect URL.The FacesContext processing this request context, String The view identifier of the target page viewId, Map<String, List<String>> A mapping of parameter names to one or more values parameters, boolean A flag indicating whether view parameters should be encoded into
this URL includeViewParams)
Return a JSF action URL derived from the |
| public abstract String | Returns: the resource URL.FacesContext for the current requestResource path to convert to a URL path)
If the value returned from this method is used as the |
| public ViewDeclarationLanguage | Returns: the ViewDeclarationLanguage, or null.the context, String FacesContext for this request.the logical view id, as returned from
viewId)deriveLogicalViewId for which the ViewDeclarationLanguage
should be returned.
Return the |
| public Stream | Returns: theStream of view idsThe facesContext, String FacesContext for this request.The initial path from which to start looking for view ids. path, int The absolute maximum depth of nested directories to visit counted from the
root ( maxDepth, ViewVisitOption... /).The options to influence the traversal. See options)ViewVisitOption for
details on those.
Return a |
| public Stream | Returns: theStream of view idsThe facesContext, String FacesContext for this request.The initial path from which to start looking for view ids. path, ViewVisitOption... The options to influence the traversal. See options)ViewVisitOption for
details on those.
Return a |
| public abstract String | Returns: the websocket URL.FacesContext for the current request.The channel name of the websocket. channel)
If the value returned from this method is used as the |
| public void | initView(FacesContext
the Faces context. context)Initialize the view for the request processing lifecycle. |
| public boolean | Returns: true if in the Set, false otherwise.the url-pattern to remove. urlPattern)
Remove the argument |
| public abstract void | renderView(FacesContext
FacesContext for the current requestthe view to render viewToRender)
Perform whatever actions are required to render the
response view to the response object associated with the current |
| public abstract UIViewRoot | Returns: the restored view root, or null.FacesContext for the current requestthe view identifier for the current request viewId)
Perform whatever actions are required to restore
the view associated with the specified |
| public abstract void | writeState(FacesContext
FacesContext for the current request
Take any appropriate action to either immediately write out the current state information (by
calling |
| CHARACTER_ENCODING_KEY | back to summary |
|---|---|
| public static final String CHARACTER_ENCODING_KEY The key, in the session's attribute set, under which the response character encoding may be stored and retrieved. | |
| DEFAULT_FACELETS_SUFFIX | back to summary |
|---|---|
| public static final String DEFAULT_FACELETS_SUFFIX The value to use for the default extension for Facelet based XHTML pages if the webapp is using url extension mapping.
| |
| DEFAULT_SUFFIX | back to summary |
|---|---|
| public static final String DEFAULT_SUFFIX The value to use for the default extension if the webapp is using url extension mapping. | |
| DEFAULT_SUFFIX_PARAM_NAME | back to summary |
|---|---|
| public static final String DEFAULT_SUFFIX_PARAM_NAME
Allow the web application to define a
list of alternate suffixes for pages containing JSF
content. This list is a space separated list of values of
the form | |
| DISABLE_FACELET_JSF_VIEWHANDLER_PARAM_NAME | back to summary |
|---|---|
| public static final String DISABLE_FACELET_JSF_VIEWHANDLER_PARAM_NAME If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the default ViewHandler must behave as specified in the latest 1.2 version of this specification. Any behavior specified in Section "Default ViewDeclarationLanguage Implementation" of the spec prose document and implemented in the default ViewHandler that pertains to handling requests for pages authored in the JavaServer Faces View Declaration Language must not be executed by the runtime.
| |
| FACELETS_BUFFER_SIZE_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_BUFFER_SIZE_PARAM_NAME The buffer size to set on the response when the ResponseWriter is generated. By default the value is 1024. A value of -1 will not assign a buffer size on the response. This should be increased if you are using development mode in order to guarantee that the response isn't partially rendered when an error is generated. The runtime must also consider the facelets.BUFFER_SIZE param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.
| |
| FACELETS_DECORATORS_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_DECORATORS_PARAM_NAME A semicolon (;) delimitted list of class names of type javax.faces.view.facelets.TagDecorator, with a no-argument constructor. These decorators will be loaded when the first request for a Facelets VDL view hits the ViewHandler for page compilation.The runtime must also consider the facelets.DECORATORS param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.
| |
| FACELETS_LIBRARIES_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_LIBRARIES_PARAM_NAME If this param is set, the runtime must interpret it as a semicolon (;) separated list of paths, starting with "/" (without the quotes). The runtime must interpret each entry in the list as a path relative to the web application root and interpret the file found at that path as a facelet tag library, conforming to the facelet taglibrary schema and expose the tags therein according to Section "Facelet Tag Library mechanism". The runtime must also consider the facelets.LIBRARIES param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.
| |
| FACELETS_REFRESH_PERIOD_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_REFRESH_PERIOD_PARAM_NAME
When a page is requested, what interval in seconds
should the compiler check for changes. If you don't want the compiler to check for changes
once the page is compiled, then use a value of -1. Setting a low refresh period helps during
development to be able to edit pages in a running application.The runtime must also consider
the facelets.REFRESH_PERIOD param name as an alias to this param name for backwards
compatibility with existing facelets tag libraries. If
| |
| FACELETS_SKIP_COMMENTS_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_SKIP_COMMENTS_PARAM_NAME If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the runtime must ensure that any XML comments in the Facelets source page are not delivered to the client. The runtime must also consider the facelets.SKIP_COMMENTS param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.
| |
| FACELETS_SUFFIX_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_SUFFIX_PARAM_NAME
Allow the web application to define an alternate suffix for Facelet based XHTML pages
containing JSF content. If this init parameter is not specified, the default value is taken
from the value of the constant
| |
| FACELETS_VIEW_MAPPINGS_PARAM_NAME | back to summary |
|---|---|
| public static final String FACELETS_VIEW_MAPPINGS_PARAM_NAME
Allow the web application to define a semicolon (;) separated list of strings that is used to
forcibly declare that certain pages in the application must be interpreted as using Facelets,
regardless of their extension. Each entry in the semicolon (;) separated list of strings is
either a file extension, as in
| |
| log | back to summary |
|---|---|
| private static final Logger log | |
| ViewHandler | back to summary |
|---|---|
| public ViewHandler() | |
| addProtectedView | back to summary |
|---|---|
| public void addProtectedView(String urlPattern)
Add the argument
| |
| calculateCharacterEncoding | back to summary |
|---|---|
| public String calculateCharacterEncoding(FacesContext context) Returns the correct character encoding to be used for this request. The following algorithm is employed.
| |
| calculateLocale | back to summary |
|---|---|
| public abstract Locale calculateLocale(FacesContext context)
Returns an appropriate
| |
| calculateRenderKitId | back to summary |
|---|---|
| public abstract String calculateRenderKitId(FacesContext context)
Return an appropriate
The default return value is
| |
| createView | back to summary |
|---|---|
| public abstract UIViewRoot createView(FacesContext context, String viewId)
Create and return a new
| |
| deriveLogicalViewId | back to summary |
|---|---|
| public String deriveLogicalViewId(FacesContext context, String requestViewId)
Derive and return the viewId from the current request, or the argument input by following the
algorithm defined in specification section JSF.7.6.2. Note that unlike
This method should work correctly when the FacesServlet is invoked via either a
The default implementation of this method simply returns requestViewId unchanged.
| |
| deriveViewId | back to summary |
|---|---|
| public String deriveViewId(FacesContext context, String requestViewId) Derive and return the viewId from the current request, or the argument input by following the algorithm defined in specification section JSF.7.6.2.
This method should work correctly when the FacesServlet is invoked via either a
The default implementation of this method simply returns requestViewId unchanged.
| |
| getActionURL | back to summary |
|---|---|
| public abstract String getActionURL(FacesContext context, String viewId)
If the value returned from this method is used as
the
| |
| getBookmarkableURL | back to summary |
|---|---|
| public String getBookmarkableURL(FacesContext context, String viewId, Map<String, List<String>> parameters, boolean includeViewParams)
Return a JSF action URL derived from the viewId argument that is suitable to be used as the
target of a link in a JSF response. Compiliant implementations must implement this method as
specified in section JSF.7.6.2. The default implementation simply calls through to
| |
| getProtectedViewsUnmodifiable | back to summary |
|---|---|
| public Set
Return an unmodifiable | |
| getRedirectURL | back to summary |
|---|---|
| public String getRedirectURL(FacesContext context, String viewId, Map<String, List<String>> parameters, boolean includeViewParams)
Return a JSF action URL derived from the
| |
| getResourceURL | back to summary |
|---|---|
| public abstract String getResourceURL(FacesContext context, String path)
If the value returned from this method is used as the
| |
| getViewDeclarationLanguage | back to summary |
|---|---|
| public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId)
Return the
The default implementation must use
The default implementation of this method returns null.
| |
| getViews | back to summary |
|---|---|
| public Stream
Return a
The
In case more than one active
| |
| getViews | back to summary |
|---|---|
| public Stream
Return a This method works as if invoking it were equivalent to evaluating the expression: Put differently, it visits all levels of the view tree.getViews(facesContext, start, Integer.MAX_VALUE, options)
In case more than one active
| |
| getWebsocketURL | back to summary |
|---|---|
| public abstract String getWebsocketURL(FacesContext context, String channel)
If the value returned from this method is used as the
| |
| initView | back to summary |
|---|---|
| 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 must perform the following actions. If
| |
| removeProtectedView | back to summary |
|---|---|
| public boolean removeProtectedView(String urlPattern)
Remove the argument
| |
| renderView | back to summary |
|---|---|
| public abstract void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException
Perform whatever actions are required to render the
response view to the response object associated with the current
Otherwise, the default implementation must obtain a reference to the
| |
| restoreView | back to summary |
|---|---|
| public abstract UIViewRoot restoreView(FacesContext context, String viewId)
Perform whatever actions are required to restore
the view associated with the specified
Otherwise, the default implementation must obtain a reference to the
| |
| writeState | back to summary |
|---|---|
| public abstract void writeState(FacesContext context) throws IOException
Take any appropriate action to either immediately write out the current state information (by
calling
This method must do nothing if the current request is an
| |