public class MultiViewHandler extends 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(FacesContext ctx,
                 String viewId,
                 Map<String,List<String>> existingParameters) | 
| Locale | calculateLocale(FacesContext context)
 This code is currently common to all  ViewHandlingStrategyinstances. | 
| String | calculateRenderKitId(FacesContext context)
 This code is currently common to all  ViewHandlingStrategyinstances. | 
| protected String | convertViewId(FacesContext context,
             String viewId)Adjust the viewID per the requirements of  renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot). | 
| UIViewRoot | createView(FacesContext context,
          String viewId)
 Derive the physical view ID (i.e. | 
| 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. | 
| protected String | derivePhysicalViewId(FacesContext ctx,
                    String requestViewId,
                    boolean checkPhysical) | 
| 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. | 
| protected Locale | findMatch(FacesContext context,
         Locale pref)Attempts to find a matching locale based on  prefand
 list of supported locales, using the matching algorithm
 as described in JSTL 8.3.2. | 
| String | getActionURL(FacesContext context,
            String viewId)
 This code is currently common to all  ViewHandlingStrategyinstances. | 
| String | getBookmarkableURL(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(FacesContext ctx,
                    String viewId,
                    Map<String,List<String>> existingParameters) | 
| Set<String> | getProtectedViewsUnmodifiable()
 Return an unmodifiable  | 
| String | getRedirectURL(FacesContext context,
              String viewId,
              Map<String,List<String>> parameters,
              boolean includeViewParams)
 Return a Jakarta Server Faces action URL derived from the  | 
| String | getResourceURL(FacesContext context,
              String path)
 This code is currently common to all  ViewHandlingStrategyinstances. | 
| ViewDeclarationLanguage | getViewDeclarationLanguage(FacesContext context,
                          String viewId)
 Return the  | 
| Stream<String> | getViews(FacesContext context,
        String path,
        int maxDepth,
        ViewVisitOption... options)
 Return a  | 
| Stream<String> | getViews(FacesContext context,
        String path,
        ViewVisitOption... options)
 Return a  | 
| String | getWebsocketURL(FacesContext context,
               String channel)
 If the value returned from this method is used as the  | 
| void | initView(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 withmapping + '/', prune the mapping from the
 URI and return it, otherwise, return the original URI. | 
| boolean | removeProtectedView(String urlPattern)
 Remove the argument  | 
| void | renderView(FacesContext context,
          UIViewRoot viewToRender)
 Call  ViewDeclarationLanguage.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)if the view can be rendered. | 
| UIViewRoot | restoreView(FacesContext context,
           String viewId) | 
| protected void | send404Error(FacesContext context)
 Send  HttpServletResponse.SC_NOT_FOUND(404) to the client. | 
| void | writeState(FacesContext context)
 This code is currently common to all  ViewHandlingStrategyinstances. | 
calculateCharacterEncodingpublic void initView(FacesContext context) throws FacesException
ViewHandler.initView(javax.faces.context.FacesContext)initView in class ViewHandlercontext - the Faces context.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(javax.faces.context.FacesContext)public UIViewRoot restoreView(FacesContext context, String viewId)
restoreView in class ViewHandlercontext - FacesContext for the current requestviewId - the view identifier for the current requestViewHandler.restoreView(javax.faces.context.FacesContext, String)public UIViewRoot createView(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 ViewHandlercontext - the Faces context.viewId - the view id.ViewHandler.restoreView(javax.faces.context.FacesContext, String)public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException
 Call ViewDeclarationLanguage.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
 if the view can be rendered.
 
renderView in class ViewHandlercontext - FacesContext for the current requestviewToRender - the view to renderIOException - if an input/output error occursFacesException - if a Jakarta Servlet error occursViewHandler.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)public Locale calculateLocale(FacesContext context)
 This code is currently common to all ViewHandlingStrategy instances.
 
calculateLocale in class ViewHandlercontext - FacesContext for the current requestViewHandler.calculateLocale(javax.faces.context.FacesContext)public String calculateRenderKitId(FacesContext context)
 This code is currently common to all ViewHandlingStrategy instances.
 
calculateRenderKitId in class ViewHandlercontext - FacesContext for the current requestViewHandler.calculateRenderKitId(javax.faces.context.FacesContext)public void writeState(FacesContext context) throws IOException
 This code is currently common to all ViewHandlingStrategy instances.
 
writeState in class ViewHandlercontext - FacesContext for the current requestIOException - if an input/output error occursViewHandler.writeState(javax.faces.context.FacesContext)public String getActionURL(FacesContext context, String viewId)
 This code is currently common to all ViewHandlingStrategy instances.
 
getActionURL in class ViewHandlercontext - FacesContext for this requestviewId - View identifier of the desired viewViewHandler.getActionURL(javax.faces.context.FacesContext, String)public String getResourceURL(FacesContext context, String path)
 This code is currently common to all ViewHandlingStrategy instances.
 
getResourceURL in class ViewHandlercontext - FacesContext for the current requestpath - Resource path to convert to a URLViewHandler.getResourceURL(javax.faces.context.FacesContext, String)public String getWebsocketURL(FacesContext context, String channel)
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 ViewHandlercontext - FacesContext for the current request.channel - The channel name of the websocket.PushContext.URI_PREFIXpublic String getBookmarkableURL(FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
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 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 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)
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 ViewHandlerurlPattern - the url-pattern to add.public Set<String> getProtectedViewsUnmodifiable()
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 ViewHandlerpublic boolean removeProtectedView(String urlPattern)
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 ViewHandlerurlPattern - the url-pattern to remove.true if in the Set, false otherwise.public String getRedirectURL(FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
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
 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 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 ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId)
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 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(FacesContext context, String path, ViewVisitOption... options)
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 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(FacesContext context, String path, int maxDepth, ViewVisitOption... options)
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 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(FacesContext context, String requestViewId)
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 ViewHandlercontext - the FacesContext for this requestrequestViewId - the viewId to derive,public String deriveLogicalViewId(FacesContext context, String requestViewId)
ViewHandler
 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
 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 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(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(FacesContext ctx, String requestViewId, boolean checkPhysical)
protected Map<String,List<String>> getFullParameterList(FacesContext ctx, String viewId, Map<String,List<String>> existingParameters)
protected void addViewParameters(FacesContext ctx, String viewId, Map<String,List<String>> existingParameters)
protected Locale findMatch(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(FacesContext context)
 Send HttpServletResponse.SC_NOT_FOUND (404) to the client.
 
context - the FacesContext for the current requestComments to: faces-dev@eclipse.org.
 Copyright © 2019 Eclipse Foundation. All rights reserved.
 Use is subject to license terms.