public class MultiViewHandler
extends javax.faces.application.ViewHandler
ViewHandler implementation handles both JSP-based and
Facelets/PDL-based views.CHARACTER_ENCODING_KEY, DEFAULT_FACELETS_SUFFIX, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME, DISABLE_FACELET_JSF_VIEWHANDLER_PARAM_NAME, FACELETS_BUFFER_SIZE_PARAM_NAME, FACELETS_DECORATORS_PARAM_NAME, FACELETS_LIBRARIES_PARAM_NAME, FACELETS_REFRESH_PERIOD_PARAM_NAME, FACELETS_SKIP_COMMENTS_PARAM_NAME, FACELETS_SUFFIX_PARAM_NAME, FACELETS_VIEW_MAPPINGS_PARAM_NAME| Constructor and Description |
|---|
MultiViewHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
addProtectedView(String urlPattern)
Add the argument
|
protected void |
addViewParameters(javax.faces.context.FacesContext ctx,
String viewId,
Map<String,List<String>> existingParameters) |
Locale |
calculateLocale(javax.faces.context.FacesContext context)
This code is currently common to all
ViewHandlingStrategy instances. |
String |
calculateRenderKitId(javax.faces.context.FacesContext context)
This code is currently common to all
ViewHandlingStrategy instances. |
protected String |
convertViewId(javax.faces.context.FacesContext context,
String viewId)
Adjust the viewID per the requirements of
renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot). |
javax.faces.component.UIViewRoot |
createView(javax.faces.context.FacesContext context,
String viewId)
Derive the physical view ID (i.e.
|
String |
deriveLogicalViewId(javax.faces.context.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. |
protected String |
derivePhysicalViewId(javax.faces.context.FacesContext ctx,
String requestViewId,
boolean checkPhysical) |
String |
deriveViewId(javax.faces.context.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. |
protected Locale |
findMatch(javax.faces.context.FacesContext context,
Locale pref)
Attempts to find a matching locale based on
pref and
list of supported locales, using the matching algorithm
as described in JSTL 8.3.2. |
String |
getActionURL(javax.faces.context.FacesContext context,
String viewId)
This code is currently common to all
ViewHandlingStrategy instances. |
String |
getBookmarkableURL(javax.faces.context.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. |
protected Map<String,List<String>> |
getFullParameterList(javax.faces.context.FacesContext ctx,
String viewId,
Map<String,List<String>> existingParameters) |
Set<String> |
getProtectedViewsUnmodifiable()
Return an unmodifiable
|
String |
getRedirectURL(javax.faces.context.FacesContext context,
String viewId,
Map<String,List<String>> parameters,
boolean includeViewParams)
Return a JSF action URL derived
from the |
String |
getResourceURL(javax.faces.context.FacesContext context,
String path)
This code is currently common to all
ViewHandlingStrategy instances. |
javax.faces.view.ViewDeclarationLanguage |
getViewDeclarationLanguage(javax.faces.context.FacesContext context,
String viewId)
Return
the |
Stream<String> |
getViews(javax.faces.context.FacesContext context,
String path,
int maxDepth,
javax.faces.application.ViewVisitOption... options)
Return a |
Stream<String> |
getViews(javax.faces.context.FacesContext context,
String path,
javax.faces.application.ViewVisitOption... options)
Return a |
String |
getWebsocketURL(javax.faces.context.FacesContext context,
String channel)
If the value returned from this
method is used as the |
void |
initView(javax.faces.context.FacesContext context)
Call the default implementation of
ViewHandler.initView(javax.faces.context.FacesContext) |
protected String |
normalizeRequestURI(String uri,
String mapping)
If the specified mapping is a prefix mapping, and the provided
request URI (usually the value from
ExternalContext.getRequestServletPath())
starts with mapping + '/', prune the mapping from the
URI and return it, otherwise, return the original URI. |
boolean |
removeProtectedView(String urlPattern)
Remove the argument
|
void |
renderView(javax.faces.context.FacesContext context,
javax.faces.component.UIViewRoot viewToRender)
Call
ViewDeclarationLanguage.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
if the view can be rendered. |
javax.faces.component.UIViewRoot |
restoreView(javax.faces.context.FacesContext context,
String viewId)
Call
ViewDeclarationLanguage.restoreView(javax.faces.context.FacesContext, String). |
protected void |
send404Error(javax.faces.context.FacesContext context)
Send
HttpServletResponse.SC_NOT_FOUND (404) to the client. |
void |
writeState(javax.faces.context.FacesContext context)
This code is currently common to all
ViewHandlingStrategy instances. |
public void initView(javax.faces.context.FacesContext context)
throws javax.faces.FacesException
ViewHandler.initView(javax.faces.context.FacesContext)initView in class javax.faces.application.ViewHandlercontext - the Faces context.javax.faces.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.ViewHandler.initView(javax.faces.context.FacesContext)public javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context,
String viewId)
Call ViewDeclarationLanguage.restoreView(javax.faces.context.FacesContext, String).
restoreView in class javax.faces.application.ViewHandlercontext - FacesContext for the current requestviewId - the view identifier for the current requestViewHandler.restoreView(javax.faces.context.FacesContext, String)public javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context,
String viewId)
Derive the physical view ID (i.e. the physical resource) and call
call ViewDeclarationLanguage.createView(javax.faces.context.FacesContext, String).
createView in class javax.faces.application.ViewHandlercontext - the Faces context.viewId - the view id.ViewHandler.restoreView(javax.faces.context.FacesContext, String)public void renderView(javax.faces.context.FacesContext context,
javax.faces.component.UIViewRoot viewToRender)
throws IOException,
javax.faces.FacesException
Call ViewDeclarationLanguage.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
if the view can be rendered.
renderView in class javax.faces.application.ViewHandlercontext - FacesContext for the current requestviewToRender - the view to renderIOException - if an input/output error occursjavax.faces.FacesException - if a servlet error occursViewHandler.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)public Locale calculateLocale(javax.faces.context.FacesContext context)
This code is currently common to all ViewHandlingStrategy instances.
calculateLocale in class javax.faces.application.ViewHandlercontext - FacesContext for the current requestViewHandler.calculateLocale(javax.faces.context.FacesContext)public String calculateRenderKitId(javax.faces.context.FacesContext context)
This code is currently common to all ViewHandlingStrategy instances.
calculateRenderKitId in class javax.faces.application.ViewHandlercontext - FacesContext for the current requestViewHandler.calculateRenderKitId(javax.faces.context.FacesContext)public void writeState(javax.faces.context.FacesContext context)
throws IOException
This code is currently common to all ViewHandlingStrategy instances.
writeState in class javax.faces.application.ViewHandlercontext - FacesContext for the current requestIOException - if an input/output error occursViewHandler.writeState(javax.faces.context.FacesContext)public String getActionURL(javax.faces.context.FacesContext context, String viewId)
This code is currently common to all ViewHandlingStrategy instances.
getActionURL in class javax.faces.application.ViewHandlercontext - FacesContext for this requestviewId - View identifier of the desired viewViewHandler.getActionURL(javax.faces.context.FacesContext, String)public String getResourceURL(javax.faces.context.FacesContext context, String path)
This code is currently common to all ViewHandlingStrategy instances.
getResourceURL in class javax.faces.application.ViewHandlercontext - FacesContext for the current requestpath - Resource path to convert to a URLViewHandler.getResourceURL(javax.faces.context.FacesContext, String)public String getWebsocketURL(javax.faces.context.FacesContext context, String channel)
javax.faces.application.ViewHandlerIf the value returned from this
method is used as the file argument to the
four-argument constructor for java.net.URL (assuming
appropriate values are used for the first three arguments), then
a client making a push handshake request to the toExternalForm() of
that URL will select the argument channel
for connecting the websocket push channel in the current view.
It must match the PushContext.URI_PREFIX of the endpoint.
getWebsocketURL in class javax.faces.application.ViewHandlercontext - FacesContext for the current request.channel - The channel name of the websocket.PushContext.URI_PREFIXpublic String getBookmarkableURL(javax.faces.context.FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
javax.faces.application.ViewHandler 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 ViewHandler.getActionURL(javax.faces.context.FacesContext, java.lang.String), passing the arguments context and
viewId.
getBookmarkableURL in class javax.faces.application.ViewHandlercontext - The FacesContext processing this requestviewId - The view identifier of the target pageparameters - A mapping of parameter names to one or more valuesincludeViewParams - A flag indicating whether view parameters should be encoded into this URLpublic void addProtectedView(String urlPattern)
javax.faces.application.ViewHandlerAdd the argument
urlPattern to the thread safe Set of
protected views for this application. Compliant implementations
make it so a subsequent call to ViewHandler.getProtectedViewsUnmodifiable() contains the argument. The
runtime must support calling this method at any time after
application startup. The default implementation takes no
action.
addProtectedView in class javax.faces.application.ViewHandlerurlPattern - the url-pattern to add.public Set<String> getProtectedViewsUnmodifiable()
javax.faces.application.ViewHandlerReturn an unmodifiable
Set of the protected views currently known to this
ViewHandler instance. Compliant implementations must
return a Set that is the concatenation of the
contents of all the <url-pattern> elements
within all the <protected-views> in all of the
application configuration resources in the current application.
The runtime must support calling this method at any time after
application startup. The default implementation returns an
unmodifiable empty Set.
getProtectedViewsUnmodifiable in class javax.faces.application.ViewHandlerpublic boolean removeProtectedView(String urlPattern)
javax.faces.application.ViewHandlerRemove the argument
urlPattern from the thread safe Set of
protected views for this application, if present in the
Set. If the argument urlPattern is not
present in the Set, this method has no effect.
Compliant implementations must make it so a subsequent call to
ViewHandler.getProtectedViewsUnmodifiable() does not contain the
argument. The runtime must support calling this method at any
time after application startup. Returns true if
this Set contained the argument. The default
implementation takes no action and returns
false.
removeProtectedView in class javax.faces.application.ViewHandlerurlPattern - the url-pattern to remove.true if in the Set, false otherwise.public String getRedirectURL(javax.faces.context.FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
javax.faces.application.ViewHandler Return a JSF action URL derived
from the viewId argument that is suitable to be used
by the NavigationHandler to issue a redirect request to
the URL using a NonFaces request. Compliant implementations
must implement this method as specified in section JSF.7.6.2.
The default implementation simply calls through to ViewHandler.getActionURL(javax.faces.context.FacesContext, java.lang.String), passing the arguments context and
viewId.
getRedirectURL in class javax.faces.application.ViewHandlercontext - The FacesContext processing this requestviewId - The view identifier of the target pageparameters - A mapping of parameter names to one or more valuesincludeViewParams - A flag indicating whether view parameters should be encoded into this URLViewHandler.getRedirectURL(javax.faces.context.FacesContext, String, java.util.Map, boolean)public javax.faces.view.ViewDeclarationLanguage getViewDeclarationLanguage(javax.faces.context.FacesContext context,
String viewId)
javax.faces.application.ViewHandlerReturn
the ViewDeclarationLanguage instance used for this ViewHandler
instance.
The default implementation must use ViewDeclarationLanguageFactory.getViewDeclarationLanguage(java.lang.String)
to obtain the appropriate ViewDeclarationLanguage
implementation for the argument viewId. Any
exceptions thrown as a result of invoking that method must not be
swallowed.
The default implementation of this method returns null.
getViewDeclarationLanguage in class javax.faces.application.ViewHandlercontext - the FacesContext for this request.viewId - the logical view
id, as returned from ViewHandler.deriveLogicalViewId(javax.faces.context.FacesContext, java.lang.String) for which the
ViewDeclarationLanguage should be returned.ViewHandler.getViewDeclarationLanguage(javax.faces.context.FacesContext, String)public Stream<String> getViews(javax.faces.context.FacesContext context, String path, javax.faces.application.ViewVisitOption... options)
javax.faces.application.ViewHandler
Return a Stream possibly lazily populated by walking the view trees of every
active ViewDeclarationLanguage rooted at a given initial path. The view tree of
every ViewDeclarationLanguage is individually traversed breadth-first as per
the contract of ViewDeclarationLanguage.getViews(FacesContext, String, int, ViewVisitOption...).
The elements in the stream are logical view ids.
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 ViewDeclarationLanguage is present, the order in which view ids
from each ViewDeclarationLanguage appear in the stream is undetermined, except for the guarantee
that every individual ViewDeclarationLanguage is traversed breadth-first.
getViews in class javax.faces.application.ViewHandlercontext - The FacesContext for this request.path - The initial path from which to start looking for view ids.options - The options to influence the traversal. See ViewVisitOption for details on those.Stream of view idspublic Stream<String> getViews(javax.faces.context.FacesContext context, String path, int maxDepth, javax.faces.application.ViewVisitOption... options)
javax.faces.application.ViewHandler
Return a Stream possibly lazily populated by walking the view trees of every
active ViewDeclarationLanguage rooted at a given initial path. The view tree of
every ViewDeclarationLanguage is individually traversed breadth-first as per
the contract of ViewDeclarationLanguage.getViews(FacesContext, String, int, ViewVisitOption...).
The elements in the stream are logical view ids.
The maxDepth parameter is the maximum depth of directory levels to visit for each
ViewDeclarationLanguage beyond the initial path, which is always visited.
The value is relative to the root (/), not to the given initial path.
E.g. given maxDepth = 3 and initial path /foo/, visiting will proceed up
to /foo/bar/, where / counts as depth 1, /foo/ as depth 2 and
/foo/bar/ as depth 3.
A value lower or equal to the depth of the initial path means that only the initial path
is visited. A value of MAX_VALUE may be used to indicate that all
levels should be visited.
In case more than one active ViewDeclarationLanguage is present, the order in which view ids
from each ViewDeclarationLanguage appear in the stream is undetermined, except for the guarantee
that every individual ViewDeclarationLanguage is traversed breadth-first.
getViews in class javax.faces.application.ViewHandlercontext - The FacesContext for this request.path - The initial path from which to start looking for view ids.maxDepth - The absolute maximum depth of nested directories to visit counted from the root (/).options - The options to influence the traversal. See ViewVisitOption for details on those.Stream of view idspublic String deriveViewId(javax.faces.context.FacesContext context, String requestViewId)
javax.faces.application.ViewHandlerDerive 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 path mapping,
extension mapping or an exact match (mapping) as
defined by Servlet.12.2. Note that path mapping is also commonly
known as prefix mapping (e.g. "/faces/*") and extension mapping
as suffix mapping (e.g. "*.xhtml"). An exact match is possible
where there's a servlet mapping with an exact URL pattern such as "/foo".
The default implementation of this method simply returns requestViewId unchanged.
deriveViewId in class javax.faces.application.ViewHandlercontext - the FacesContext for this requestrequestViewId - the viewId to derive,public String deriveLogicalViewId(javax.faces.context.FacesContext context, String requestViewId)
javax.faces.application.ViewHandlerDerive 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 deriveViewId(), this method does not require that
a physical view be present.
This method should work correctly when the
FacesServlet is invoked via either a path mapping,
extension mapping or an exact match (mapping) as
defined by Servlet.12.2. Note that path mapping is also commonly
known as prefix mapping (e.g. "/faces/*") and extension mapping
as suffix mapping (e.g. "*.xhtml"). An exact match is possible
where there's a servlet mapping with an exact URL pattern such as "/foo".
The default implementation of this method simply returns requestViewId unchanged.
deriveLogicalViewId in class javax.faces.application.ViewHandlercontext - the FacesContext for this requestrequestViewId - the viewId to derive,protected String normalizeRequestURI(String uri, String mapping)
If the specified mapping is a prefix mapping, and the provided
request URI (usually the value from ExternalContext.getRequestServletPath())
starts with mapping + '/', prune the mapping from the
URI and return it, otherwise, return the original URI.
uri - the servlet request pathmapping - the FacesServlet mapping used for this requestprotected String convertViewId(javax.faces.context.FacesContext context, String viewId)
Adjust the viewID per the requirements of renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot).
context - current FacesContextviewId - incoming view IDprotected String derivePhysicalViewId(javax.faces.context.FacesContext ctx, String requestViewId, boolean checkPhysical)
protected Map<String,List<String>> getFullParameterList(javax.faces.context.FacesContext ctx, String viewId, Map<String,List<String>> existingParameters)
protected void addViewParameters(javax.faces.context.FacesContext ctx,
String viewId,
Map<String,List<String>> existingParameters)
protected Locale findMatch(javax.faces.context.FacesContext context, Locale pref)
pref and
list of supported locales, using the matching algorithm
as described in JSTL 8.3.2.context - the FacesContext for the current requestpref - the preferred localeprotected void send404Error(javax.faces.context.FacesContext context)
Send HttpServletResponse.SC_NOT_FOUND (404) to the client.
context - the FacesContext for the current requestCopyright © 2010–2018 JBoss by Red Hat. All rights reserved.