public class MultiViewHandler
extends jakarta.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(jakarta.faces.context.FacesContext ctx,
String viewId,
Map<String,List<String>> existingParameters) |
Locale |
calculateLocale(jakarta.faces.context.FacesContext context)
This code is currently common to all
ViewHandlingStrategy instances. |
String |
calculateRenderKitId(jakarta.faces.context.FacesContext context)
This code is currently common to all
ViewHandlingStrategy instances. |
protected String |
convertViewId(jakarta.faces.context.FacesContext context,
String viewId)
Adjust the viewID per the requirements of
renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot). |
jakarta.faces.component.UIViewRoot |
createView(jakarta.faces.context.FacesContext context,
String viewId)
Derive the physical view ID (i.e.
|
String |
deriveLogicalViewId(jakarta.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 7.6.2. |
protected String |
derivePhysicalViewId(jakarta.faces.context.FacesContext ctx,
String requestViewId,
boolean checkPhysical) |
String |
deriveViewId(jakarta.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 7.6.2. |
protected Locale |
findMatch(jakarta.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(jakarta.faces.context.FacesContext context,
String viewId)
This code is currently common to all
ViewHandlingStrategy instances. |
String |
getBookmarkableURL(jakarta.faces.context.FacesContext context,
String viewId,
Map<String,List<String>> parameters,
boolean includeViewParams)
Return a Jakarta Server Faces action URL derived from the viewId argument that is suitable to be used as the target of a link in a Jakarta Server Faces response. |
protected Map<String,List<String>> |
getFullParameterList(jakarta.faces.context.FacesContext ctx,
String viewId,
Map<String,List<String>> existingParameters) |
Set<String> |
getProtectedViewsUnmodifiable()
Return an unmodifiable |
String |
getRedirectURL(jakarta.faces.context.FacesContext context,
String viewId,
Map<String,List<String>> parameters,
boolean includeViewParams)
Return a Jakarta Server Faces action URL derived from the |
String |
getResourceURL(jakarta.faces.context.FacesContext context,
String path)
This code is currently common to all
ViewHandlingStrategy instances. |
jakarta.faces.view.ViewDeclarationLanguage |
getViewDeclarationLanguage(jakarta.faces.context.FacesContext context,
String viewId)
Return the |
Stream<String> |
getViews(jakarta.faces.context.FacesContext context,
String path,
int maxDepth,
jakarta.faces.application.ViewVisitOption... options)
Return a |
Stream<String> |
getViews(jakarta.faces.context.FacesContext context,
String path,
jakarta.faces.application.ViewVisitOption... options)
Return a |
String |
getWebsocketURL(jakarta.faces.context.FacesContext context,
String channel)
If the value returned from this method is used as the |
void |
initView(jakarta.faces.context.FacesContext context)
Call the default implementation of
ViewHandler.initView(jakarta.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(jakarta.faces.context.FacesContext context,
jakarta.faces.component.UIViewRoot viewToRender)
Call
ViewDeclarationLanguage.renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot) if
the view can be rendered. |
jakarta.faces.component.UIViewRoot |
restoreView(jakarta.faces.context.FacesContext context,
String viewId)
Call
ViewDeclarationLanguage.restoreView(jakarta.faces.context.FacesContext, String). |
protected void |
send404Error(jakarta.faces.context.FacesContext context)
Send
HttpServletResponse.SC_NOT_FOUND (404) to the client. |
void |
writeState(jakarta.faces.context.FacesContext context)
This code is currently common to all
ViewHandlingStrategy instances. |
public void initView(jakarta.faces.context.FacesContext context)
throws jakarta.faces.FacesException
ViewHandler.initView(jakarta.faces.context.FacesContext)initView in class jakarta.faces.application.ViewHandlercontext - the Faces context.jakarta.faces.FacesException - if a problem occurs setting the encoding, such as the
UnsupportedEncodingException thrown by the underlying Jakarta Servlet or Portlet technology when the
encoding is not supported.ViewHandler.initView(jakarta.faces.context.FacesContext)public jakarta.faces.component.UIViewRoot restoreView(jakarta.faces.context.FacesContext context,
String viewId)
Call ViewDeclarationLanguage.restoreView(jakarta.faces.context.FacesContext, String).
restoreView in class jakarta.faces.application.ViewHandlercontext - FacesContext for the current requestviewId - the view identifier for the current requestViewHandler.restoreView(jakarta.faces.context.FacesContext, String)public jakarta.faces.component.UIViewRoot createView(jakarta.faces.context.FacesContext context,
String viewId)
Derive the physical view ID (i.e. the physical resource) and call call
ViewDeclarationLanguage.createView(jakarta.faces.context.FacesContext, String).
createView in class jakarta.faces.application.ViewHandlercontext - the Faces context.viewId - the view id.ViewHandler.restoreView(jakarta.faces.context.FacesContext, String)public void renderView(jakarta.faces.context.FacesContext context,
jakarta.faces.component.UIViewRoot viewToRender)
throws IOException,
jakarta.faces.FacesException
Call
ViewDeclarationLanguage.renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot) if
the view can be rendered.
renderView in class jakarta.faces.application.ViewHandlercontext - FacesContext for the current requestviewToRender - the view to renderIOException - if an input/output error occursjakarta.faces.FacesException - if a Jakarta Servlet error occursViewHandler.renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot)public Locale calculateLocale(jakarta.faces.context.FacesContext context)
This code is currently common to all ViewHandlingStrategy instances.
calculateLocale in class jakarta.faces.application.ViewHandlercontext - FacesContext for the current requestViewHandler.calculateLocale(jakarta.faces.context.FacesContext)public String calculateRenderKitId(jakarta.faces.context.FacesContext context)
This code is currently common to all ViewHandlingStrategy instances.
calculateRenderKitId in class jakarta.faces.application.ViewHandlercontext - FacesContext for the current requestViewHandler.calculateRenderKitId(jakarta.faces.context.FacesContext)public void writeState(jakarta.faces.context.FacesContext context)
throws IOException
This code is currently common to all ViewHandlingStrategy instances.
writeState in class jakarta.faces.application.ViewHandlercontext - FacesContext for the current requestIOException - if an input/output error occursViewHandler.writeState(jakarta.faces.context.FacesContext)public String getActionURL(jakarta.faces.context.FacesContext context, String viewId)
This code is currently common to all ViewHandlingStrategy instances.
getActionURL in class jakarta.faces.application.ViewHandlercontext - FacesContext for this requestviewId - View identifier of the desired viewViewHandler.getActionURL(jakarta.faces.context.FacesContext, String)public String getResourceURL(jakarta.faces.context.FacesContext context, String path)
This code is currently common to all ViewHandlingStrategy instances.
getResourceURL in class jakarta.faces.application.ViewHandlercontext - FacesContext for the current requestpath - Resource path to convert to a URLViewHandler.getResourceURL(jakarta.faces.context.FacesContext, String)public String getWebsocketURL(jakarta.faces.context.FacesContext context, String channel)
jakarta.faces.application.ViewHandler
If 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 jakarta.faces.application.ViewHandlercontext - FacesContext for the current request.channel - The channel name of the websocket.PushContext.URI_PREFIXpublic String getBookmarkableURL(jakarta.faces.context.FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
jakarta.faces.application.ViewHandler
Return a Jakarta Server Faces action URL derived from the viewId argument that is suitable to be used as the target
of a link in a Jakarta Server Faces response. Compliant implementations must implement this method as specified in
section 7.6.2. The default implementation simply calls through to ViewHandler.getActionURL(jakarta.faces.context.FacesContext, java.lang.String), passing the arguments
context and viewId.
getBookmarkableURL in class jakarta.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)
jakarta.faces.application.ViewHandler
Add 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 jakarta.faces.application.ViewHandlerurlPattern - the url-pattern to add.public Set<String> getProtectedViewsUnmodifiable()
jakarta.faces.application.ViewHandler
Return 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 jakarta.faces.application.ViewHandlerpublic boolean removeProtectedView(String urlPattern)
jakarta.faces.application.ViewHandler
Remove 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 jakarta.faces.application.ViewHandlerurlPattern - the url-pattern to remove.true if in the Set, false otherwise.public String getRedirectURL(jakarta.faces.context.FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
jakarta.faces.application.ViewHandler
Return a Jakarta Server Faces 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 7.6.2. The default implementation simply calls
through to ViewHandler.getActionURL(jakarta.faces.context.FacesContext, java.lang.String), passing the arguments context and viewId.
getRedirectURL in class jakarta.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(jakarta.faces.context.FacesContext, String, java.util.Map, boolean)public jakarta.faces.view.ViewDeclarationLanguage getViewDeclarationLanguage(jakarta.faces.context.FacesContext context,
String viewId)
jakarta.faces.application.ViewHandler
Return 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 jakarta.faces.application.ViewHandlercontext - the FacesContext for this request.viewId - the logical view id, as returned from ViewHandler.deriveLogicalViewId(jakarta.faces.context.FacesContext, java.lang.String)
for which the ViewDeclarationLanguage should be returned.ViewHandler.getViewDeclarationLanguage(jakarta.faces.context.FacesContext, String)public Stream<String> getViews(jakarta.faces.context.FacesContext context, String path, jakarta.faces.application.ViewVisitOption... options)
jakarta.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 jakarta.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(jakarta.faces.context.FacesContext context, String path, int maxDepth, jakarta.faces.application.ViewVisitOption... options)
jakarta.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 jakarta.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(jakarta.faces.context.FacesContext context, String requestViewId)
jakarta.faces.application.ViewHandlerDerive and return the viewId from the current request, or the argument input by following the algorithm defined in specification section 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 jakarta.faces.application.ViewHandlercontext - the FacesContext for this requestrequestViewId - the viewId to derive,public String deriveLogicalViewId(jakarta.faces.context.FacesContext context, String requestViewId)
jakarta.faces.application.ViewHandler
Derive and return the viewId from the current request, or the argument input by following the algorithm defined in
specification section 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 jakarta.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(jakarta.faces.context.FacesContext context, String viewId)
Adjust the viewID per the requirements of renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot).
context - current FacesContextviewId - incoming view IDprotected String derivePhysicalViewId(jakarta.faces.context.FacesContext ctx, String requestViewId, boolean checkPhysical)
protected Map<String,List<String>> getFullParameterList(jakarta.faces.context.FacesContext ctx, String viewId, Map<String,List<String>> existingParameters)
protected void addViewParameters(jakarta.faces.context.FacesContext ctx,
String viewId,
Map<String,List<String>> existingParameters)
protected Locale findMatch(jakarta.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(jakarta.faces.context.FacesContext context)
Send HttpServletResponse.SC_NOT_FOUND (404) to the client.
context - the FacesContext for the current requestCopyright © 2010–2022 JBoss by Red Hat. All rights reserved.