Class ViewHandler
- java.lang.Object
-
- jakarta.faces.application.ViewHandler
-
- Direct Known Subclasses:
ViewHandlerWrapper
public abstract class ViewHandler extends Object
ViewHandler is the pluggablity mechanism for allowing implementations of or applications using the Jakarta 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
StateManagerfor information on how theViewHandlerinteracts theStateManager.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 Jakarta Faces
UIComponents. Any of the responsibilities of theViewHandlerthat specifically deal with the VDL sub-system are now the domain of the VDL implementation. These responsibilities are defined on theViewDeclarationLanguageclass. TheViewHandlerprovidesgetViewDeclarationLanguage(jakarta.faces.context.FacesContext, java.lang.String)as a convenience method to access the VDL implementation given aviewId.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCHARACTER_ENCODING_KEYThe key, in the session's attribute set, under which the response character encoding may be stored and retrieved.static StringDEFAULT_FACELETS_SUFFIXThe value to use for the default extension for Facelet based XHTML pages if the webapp is using url extension mapping.static StringDEFAULT_SUFFIXDeprecated, for removal: This API element is subject to removal in a future version.UseDEFAULT_FACELETS_SUFFIXinstead.static StringDEFAULT_SUFFIX_PARAM_NAMEDeprecated, for removal: This API element is subject to removal in a future version.UseFACELETS_SUFFIX_PARAM_NAMEinstead.static StringFACELETS_BUFFER_SIZE_PARAM_NAMEThe buffer size to set on the response when the ResponseWriter is generated.static StringFACELETS_DECORATORS_PARAM_NAMEA semicolon (;) delimitted list of class names of type jakarta.faces.view.facelets.TagDecorator, with a no-argument constructor.static StringFACELETS_LIBRARIES_PARAM_NAMEIf this param is set, the runtime must interpret it as a semicolon (;) separated list of paths, starting with "/" (without the quotes).static StringFACELETS_REFRESH_PERIOD_PARAM_NAMEWhen a page is requested, what interval in seconds should the compiler check for changes.static StringFACELETS_SKIP_COMMENTS_PARAM_NAMEIf 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.static StringFACELETS_SUFFIX_PARAM_NAMEAllow the web application to define a list of alternate suffixes for Facelet based XHTML pages containing Jakarta Faces content.static StringFACELETS_VIEW_MAPPINGS_PARAM_NAMEAllow 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.
-
Constructor Summary
Constructors Constructor Description ViewHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddProtectedView(String urlPattern)Add the argumenturlPatternto the thread safeSetof protected views for this application.StringcalculateCharacterEncoding(FacesContext context)Returns the correct character encoding to be used for this request.abstract LocalecalculateLocale(FacesContext context)Returns an appropriateLocaleto use for this and subsequent requests for the current client.abstract StringcalculateRenderKitId(FacesContext context)Return an appropriaterenderKitIdfor this and subsequent requests from the current client.abstract UIViewRootcreateView(FacesContext context, String viewId)Create and return a newUIViewRootinstance initialized with information from the argumentFacesContextandviewId.StringderiveLogicalViewId(FacesContext context, String requestViewId)Derive and return the viewId from the current request, or the argument input by following the algorithm defined in section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document.StringderiveViewId(FacesContext context, String requestViewId)Derive and return the viewId from the current request, or the argument input by following the algorithm defined in section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document.abstract StringgetActionURL(FacesContext context, String viewId)If the value returned from this method is used as thefileargument to the four-argument constructor forjava.net.URL(assuming appropriate values are used for the first three arguments), then a client making a request to thetoExternalForm()of thatURLwill select the argumentviewIdfor traversing the Jakarta Faces lifecycle.StringgetBookmarkableURL(FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)Return a Jakarta Faces action URL derived from the viewId argument that is suitable to be used as the target of a link in a Jakarta Faces response.Set<String>getProtectedViewsUnmodifiable()Return an unmodifiableSetof the protected views currently known to thisViewHandlerinstance.StringgetRedirectURL(FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)Return a Jakarta Faces action URL derived from theviewIdargument that is suitable to be used by theNavigationHandlerto issue a redirect request to the URL using a NonFaces request.abstract StringgetResourceURL(FacesContext context, String path)If the value returned from this method is used as thefileargument to the four-argument constructor forjava.net.URL(assuming appropriate values are used for the first three arguments), then a client making a request to thetoExternalForm()of thatURLwill select the argumentpathfor direct rendering.ViewDeclarationLanguagegetViewDeclarationLanguage(FacesContext context, String viewId)Stream<String>getViews(FacesContext facesContext, String path, int maxDepth, ViewVisitOption... options)Return aStreampossibly lazily populated by walking the view trees of every activeViewDeclarationLanguagerooted at a given initial path.Stream<String>getViews(FacesContext facesContext, String path, ViewVisitOption... options)Return aStreampossibly lazily populated by walking the view trees of every activeViewDeclarationLanguagerooted at a given initial path.abstract StringgetWebsocketURL(FacesContext context, String channel)If the value returned from this method is used as thefileargument to the four-argument constructor forjava.net.URL(assuming appropriate values are used for the first three arguments), then a client making a push handshake request to thetoExternalForm()of thatURLwill select the argumentchannelfor connecting the websocket push channel in the current view.voidinitView(FacesContext context)Initialize the view for the request processing lifecycle.booleanremoveProtectedView(String urlPattern)Remove the argumenturlPatternfrom the thread safeSetof protected views for this application, if present in theSet.abstract voidrenderView(FacesContext context, UIViewRoot viewToRender)Perform whatever actions are required to render the response view to the response object associated with the currentFacesContext.abstract UIViewRootrestoreView(FacesContext context, String viewId)Perform whatever actions are required to restore the view associated with the specifiedFacesContextandviewId.abstract voidwriteState(FacesContext context)Take any appropriate action to either immediately write out the current state information (by callingStateManager.writeState(jakarta.faces.context.FacesContext, java.lang.Object), or noting where state information should later be written.
-
-
-
Field Detail
-
CHARACTER_ENCODING_KEY
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.
- See Also:
- Constant Field Values
-
DEFAULT_SUFFIX_PARAM_NAME
@Deprecated(since="4.0", forRemoval=true) public static final String DEFAULT_SUFFIX_PARAM_NAME
Deprecated, for removal: This API element is subject to removal in a future version.UseFACELETS_SUFFIX_PARAM_NAMEinstead.This is not anymore used since removal of support for Jakarta Pages.
- See Also:
- Constant Field Values
-
DEFAULT_SUFFIX
@Deprecated(since="4.0", forRemoval=true) public static final String DEFAULT_SUFFIX
Deprecated, for removal: This API element is subject to removal in a future version.UseDEFAULT_FACELETS_SUFFIXinstead.This is not anymore used since removal of support for Jakarta Pages.
- See Also:
- Constant Field Values
-
FACELETS_SKIP_COMMENTS_PARAM_NAME
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.
- Since:
- 2.0
- See Also:
- Constant Field Values
-
FACELETS_SUFFIX_PARAM_NAME
public static final String FACELETS_SUFFIX_PARAM_NAME
Allow the web application to define a list of alternate suffixes for Facelet based XHTML pages containing Jakarta Faces content. This list is a space separated list of values of the form
.<extension>. The first physical resource whose extension matches one of the configured extensions will be the suffix used to create the view ID. If this init parameter is not specified, the default value is taken from the value of the constantDEFAULT_FACELETS_SUFFIX- Since:
- 2.0
- See Also:
- Constant Field Values
-
DEFAULT_FACELETS_SUFFIX
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.
- Since:
- 2.0
- See Also:
- Constant Field Values
-
FACELETS_VIEW_MAPPINGS_PARAM_NAME
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
*.xhtml, or a resource prefix (starting with '/' and interpreted as relative to the web application root), as in/user/*. The latter class of entry can also take the form of/<filename>.<extension>*such as/login.xhtml*.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FACELETS_BUFFER_SIZE_PARAM_NAME
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.
- Since:
- 2.0
- See Also:
- Constant Field Values
-
FACELETS_REFRESH_PERIOD_PARAM_NAME
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
ProjectStageis set toProductionand this value is not otherwise specified, the runtime must act as if it is set to -1.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FACELETS_LIBRARIES_PARAM_NAME
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.
- Since:
- 2.0
- See Also:
- Constant Field Values
-
FACELETS_DECORATORS_PARAM_NAME
public static final String FACELETS_DECORATORS_PARAM_NAME
A semicolon (;) delimitted list of class names of type jakarta.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.
- Since:
- 2.0
- See Also:
- Constant Field Values
-
-
Method Detail
-
initView
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
ExternalContext.getRequestCharacterEncoding()returnsnull, callcalculateCharacterEncoding(jakarta.faces.context.FacesContext)and pass the result, if non-null, into theExternalContext.setRequestCharacterEncoding(java.lang.String)method. IfExternalContext.getRequestCharacterEncoding()returns non-nulltake no action.- Parameters:
context- the Faces context.- Throws:
FacesException- if a problem occurs setting the encoding, such as theUnsupportedEncodingExceptionthrown by the underlying Jakarta Servlet or Portlet technology when the encoding is not supported.
-
restoreView
public abstract UIViewRoot restoreView(FacesContext context, String viewId)
Perform whatever actions are required to restore the view associated with the specified
FacesContextandviewId. It may delegate to therestoreViewof the associatedStateManagerto do the actual work of restoring the view. If there is no available state for the specifiedviewId, returnnull.Otherwise, the default implementation must obtain a reference to the
ViewDeclarationLanguagefor thisviewIdand call itsViewDeclarationLanguage.restoreView(jakarta.faces.context.FacesContext, java.lang.String)method, returning the result and not swallowing any exceptions thrown by that method.- Parameters:
context-FacesContextfor the current requestviewId- the view identifier for the current request- Returns:
- the restored view root, or null.
- Throws:
NullPointerException- ifcontextisnullFacesException- if a Jakarta Servlet error occurs
-
createView
public abstract UIViewRoot createView(FacesContext context, String viewId)
Create and return a new
UIViewRootinstance initialized with information from the argumentFacesContextandviewId. Locate theViewDeclarationLanguageimplementation for the VDL used in the view. The argumentviewIdmust be converted to a physicalviewIdthat can refer to an actual resource suitable for use by theViewDeclarationLanguageViewDeclarationLanguage.createView(jakarta.faces.context.FacesContext, java.lang.String), which must be called by this method.- Parameters:
context- the Faces context.viewId- the view id.- Returns:
- the viewroot.
- Throws:
NullPointerException- ifcontextisnull
-
renderView
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
FacesContext.Otherwise, the default implementation must obtain a reference to the
ViewDeclarationLanguagefor theviewIdof the argumentviewToRenderand call itsViewDeclarationLanguage.renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot)method, returning the result and not swallowing any exceptions thrown by that method.- Parameters:
context-FacesContextfor the current requestviewToRender- the view to render- Throws:
IOException- if an input/output error occursNullPointerException- ifcontextorviewToRenderisnullFacesException- if a Jakarta Servlet error occurs
-
calculateLocale
public abstract Locale calculateLocale(FacesContext context)
Returns an appropriate
Localeto use for this and subsequent requests for the current client.- Parameters:
context-FacesContextfor the current request- Returns:
- the locale.
- Throws:
NullPointerException- ifcontextisnull
-
calculateCharacterEncoding
public String calculateCharacterEncoding(FacesContext context)
Returns the correct character encoding to be used for this request.
The following algorithm is employed.
-
Examine the
Content-Typerequest header. If it has acharsetparameter, extract it and return that as the encoding. -
If no
charsetparameter was found, check for the existence of a session by callingExternalContext.getSession(boolean)passingfalseas the argument. If that method returnstrue, get the session Map by callingExternalContext.getSessionMap()and look for a value under the key given by the value of the symbolic constantCHARACTER_ENCODING_KEY. If present, return the value, converted to String. -
Otherwise, return
null
- Parameters:
context- the Faces context.- Returns:
- the character encoding, or
null - Since:
- 1.2
-
-
calculateRenderKitId
public abstract String calculateRenderKitId(FacesContext context)
Return an appropriate
renderKitIdfor this and subsequent requests from the current client. It is an error for this method to returnnull.The default return value is
RenderKitFactory.HTML_BASIC_RENDER_KIT.- Parameters:
context-FacesContextfor the current request- Returns:
- the render kit id.
- Throws:
NullPointerException- ifcontextisnull
-
deriveViewId
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 section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document.
This method should work correctly when the FacesServlet is invoked via either a
path mapping,extension mappingor anexact match(mapping) as defined by Servlet.12.2. Note thatpath mappingis also commonly known as prefix mapping (e.g. "/faces/*") andextension mappingas suffix mapping (e.g. "*.xhtml"). Anexact matchis 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.
- Parameters:
context- theFacesContextfor this requestrequestViewId- theviewIdto derive,- Returns:
- the derived view id.
- Since:
- 2.0
-
deriveLogicalViewId
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 section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document. 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 mappingor anexact match(mapping) as defined by Servlet.12.2. Note thatpath mappingis also commonly known as prefix mapping (e.g. "/faces/*") andextension mappingas suffix mapping (e.g. "*.xhtml"). Anexact matchis 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.
- Parameters:
context- theFacesContextfor this requestrequestViewId- theviewIdto derive,- Returns:
- the derived logical view id.
- Since:
- 2.1
-
getActionURL
public abstract String getActionURL(FacesContext context, String viewId)
If the value returned from this method is used as the
fileargument to the four-argument constructor forjava.net.URL(assuming appropriate values are used for the first three arguments), then a client making a request to thetoExternalForm()of thatURLwill select the argumentviewIdfor traversing the Jakarta Faces lifecycle. Please see section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document for the complete specification, especially for details related to view protection using theResponseStateManager.NON_POSTBACK_VIEW_TOKEN_PARAMand the behavior when the current request is to a URL for which the FacesServlet has an exact mapping as defined by Servlet.12.2.- Parameters:
context-FacesContextfor this requestviewId- View identifier of the desired view- Returns:
- the action url.
- Throws:
IllegalArgumentException- ifviewIdis not valid for thisViewHandler, or does not start with "/".NullPointerException- ifcontextorviewIdisnull.
-
getRedirectURL
public String getRedirectURL(FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
Return a Jakarta Faces action URL derived from the
viewIdargument that is suitable to be used by theNavigationHandlerto issue a redirect request to the URL using a NonFaces request. Compliant implementations must implement this method as specified in section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document. The default implementation simply calls through togetActionURL(jakarta.faces.context.FacesContext, java.lang.String), passing the argumentscontextandviewId.- Parameters:
context- 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 URL- Returns:
- the redirect URL.
- Since:
- 2.0
-
getBookmarkableURL
public String getBookmarkableURL(FacesContext context, String viewId, Map<String,List<String>> parameters, boolean includeViewParams)
Return a Jakarta Faces action URL derived from the viewId argument that is suitable to be used as the target of a link in a Jakarta Faces response. Compliant implementations must implement this method as specified in section 7.6.2 "Default ViewHandler Implementation" of the Jakarta Faces Specification Document. The default implementation simply calls through to
getActionURL(jakarta.faces.context.FacesContext, java.lang.String), passing the argumentscontextandviewId.- Parameters:
context- 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 URL- Returns:
- the bookmarkable URL.
- Since:
- 2.0
-
getResourceURL
public abstract String getResourceURL(FacesContext context, String path)
If the value returned from this method is used as the
fileargument to the four-argument constructor forjava.net.URL(assuming appropriate values are used for the first three arguments), then a client making a request to thetoExternalForm()of thatURLwill select the argumentpathfor direct rendering. 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.- Parameters:
context-FacesContextfor the current requestpath- Resource path to convert to a URL- Returns:
- the resource URL.
- Throws:
IllegalArgumentException- ifviewIdis not valid for thisViewHandler.NullPointerException- ifcontextorpathisnull.
-
getWebsocketURL
public abstract String getWebsocketURL(FacesContext context, String channel)
If the value returned from this method is used as the
fileargument to the four-argument constructor forjava.net.URL(assuming appropriate values are used for the first three arguments), then a client making a push handshake request to thetoExternalForm()of thatURLwill select the argumentchannelfor connecting the websocket push channel in the current view. It must match thePushContext.URI_PREFIXof the endpoint.- Parameters:
context-FacesContextfor the current request.channel- The channel name of the websocket.- Returns:
- the websocket URL.
- Throws:
NullPointerException- ifcontextorchannelisnull.- See Also:
PushContext.URI_PREFIX
-
getProtectedViewsUnmodifiable
public Set<String> getProtectedViewsUnmodifiable()
Return an unmodifiable
Setof the protected views currently known to thisViewHandlerinstance. Compliant implementations must return aSetthat 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 emptySet.- Returns:
- the unmodifiable set of protected views.
- Since:
- 2.2
-
addProtectedView
public void addProtectedView(String urlPattern)
Add the argument
urlPatternto the thread safeSetof protected views for this application. Compliant implementations make it so a subsequent call togetProtectedViewsUnmodifiable()contains the argument. The runtime must support calling this method at any time after application startup. The default implementation takes no action.- Parameters:
urlPattern- the url-pattern to add.- Since:
- 2.2
-
removeProtectedView
public boolean removeProtectedView(String urlPattern)
Remove the argument
urlPatternfrom the thread safeSetof protected views for this application, if present in theSet. If the argumenturlPatternis not present in theSet, this method has no effect. Compliant implementations must make it so a subsequent call togetProtectedViewsUnmodifiable()does not contain the argument. The runtime must support calling this method at any time after application startup. Returnstrueif thisSetcontained the argument. The default implementation takes no action and returnsfalse.- Parameters:
urlPattern- the url-pattern to remove.- Returns:
trueif in theSet,falseotherwise.- Since:
- 2.2
-
getViewDeclarationLanguage
public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId)
Return the
ViewDeclarationLanguageinstance used for thisViewHandlerinstance.The default implementation must use
ViewDeclarationLanguageFactory.getViewDeclarationLanguage(java.lang.String)to obtain the appropriateViewDeclarationLanguageimplementation for the argumentviewId. Any exceptions thrown as a result of invoking that method must not be swallowed.The default implementation of this method returns null.
- Parameters:
context- theFacesContextfor this request.viewId- the logical view id, as returned fromderiveLogicalViewId(jakarta.faces.context.FacesContext, java.lang.String)for which theViewDeclarationLanguageshould be returned.- Returns:
- the ViewDeclarationLanguage, or null.
- Since:
- 2.0
-
getViews
public Stream<String> getViews(FacesContext facesContext, String path, int maxDepth, ViewVisitOption... options)
Return a
Streampossibly lazily populated by walking the view trees of every activeViewDeclarationLanguagerooted at a given initial path. The view tree of everyViewDeclarationLanguageis individually traversed breadth-first as per the contract ofViewDeclarationLanguage.getViews(FacesContext, String, int, ViewVisitOption...). The elements in the stream are logical view ids.The
maxDepthparameter is the maximum depth of directory levels to visit for eachViewDeclarationLanguagebeyond the initial path, which is always visited. The value is relative to the root (/), not to the given initial path. E.g. givenmaxDepth=3and initial path/foo/, visiting will proceed up to/foo/bar/, where/counts as depth1,/foo/as depth2and/foo/bar/as depth3. A value lower or equal to the depth of the initial path means that only the initial path is visited. A value ofMAX_VALUEmay be used to indicate that all levels should be visited.In case more than one active
ViewDeclarationLanguageis present, the order in which view ids from eachViewDeclarationLanguageappear in the stream is undetermined, except for the guarantee that every individualViewDeclarationLanguageis traversed breadth-first.- Parameters:
facesContext- TheFacesContextfor 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. SeeViewVisitOptionfor details on those.- Returns:
- the
Streamof view ids - Since:
- 2.3
-
getViews
public Stream<String> getViews(FacesContext facesContext, String path, ViewVisitOption... options)
Return a
Streampossibly lazily populated by walking the view trees of every activeViewDeclarationLanguagerooted at a given initial path. The view tree of everyViewDeclarationLanguageis individually traversed breadth-first as per the contract ofViewDeclarationLanguage.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
ViewDeclarationLanguageis present, the order in which view ids from eachViewDeclarationLanguageappear in the stream is undetermined, except for the guarantee that every individualViewDeclarationLanguageis traversed breadth-first.- Parameters:
facesContext- TheFacesContextfor this request.path- The initial path from which to start looking for view ids.options- The options to influence the traversal. SeeViewVisitOptionfor details on those.- Returns:
- the
Streamof view ids - Since:
- 2.3
-
writeState
public abstract void writeState(FacesContext context) throws IOException
Take any appropriate action to either immediately write out the current state information (by calling
StateManager.writeState(jakarta.faces.context.FacesContext, java.lang.Object), or noting where state information should later be written.This method must do nothing if the current request is an
Ajaxrequest. When responding toAjaxrequests, the state is obtained by callingStateManager.getViewState(jakarta.faces.context.FacesContext)and then written into theAjaxresponse during final encoding (PartialViewContext.processPartial(jakarta.faces.event.PhaseId)) .- Parameters:
context-FacesContextfor the current request- Throws:
IOException- if an input/output error occursNullPointerException- ifcontextisnull
-
-