Package org.apache.myfaces.application
Class ViewIdSupport
- java.lang.Object
-
- org.apache.myfaces.application.ViewIdSupport
-
public class ViewIdSupport extends Object
A ViewHandlerSupport implementation for use with standard Java Servlet engines, ie an engine that supports jakarta.servlet, and uses a standard web.xml file.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ViewIdSupport(FacesContext facesContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
calculateActionURL(FacesContext context, String viewId)
Return a string containing a webapp-relative URL that the user can invoke to render the specified view.String
calculateViewId(FacesContext facesContext)
Calculates the view id from the given faces context by the following algorithmString
deriveLogicalViewId(FacesContext context, String rawViewId)
String
deriveViewId(FacesContext context, String viewId)
protected String
deriveViewId(FacesContext context, String rawViewId, boolean checkViewExists)
static ViewIdSupport
getInstance(FacesContext facesContext)
protected String
handlePrefixMapping(String viewId, String prefix)
Return the normalized viewId according to the algorithm specified in 7.5.2 by stripping off any number of occurrences of the prefix mapping from the viewId.protected String
handleSuffixMapping(FacesContext context, String requestViewId)
Return the viewId with any non-standard suffix stripped off and replaced with the default suffix configured for the specified context.boolean
isViewExistent(FacesContext facesContext, String viewId)
Check if a view existsboolean
isViewProtected(FacesContext context, String viewId)
-
-
-
Constructor Detail
-
ViewIdSupport
protected ViewIdSupport(FacesContext facesContext)
-
-
Method Detail
-
getInstance
public static ViewIdSupport getInstance(FacesContext facesContext)
-
deriveLogicalViewId
public String deriveLogicalViewId(FacesContext context, String rawViewId)
-
deriveViewId
public String deriveViewId(FacesContext context, String viewId)
-
deriveViewId
protected String deriveViewId(FacesContext context, String rawViewId, boolean checkViewExists)
-
calculateActionURL
public String calculateActionURL(FacesContext context, String viewId)
Return a string containing a webapp-relative URL that the user can invoke to render the specified view.URLs and ViewIds are not quite the same; for example a url of "/foo.jsf" or "/faces/foo.jsp" may be needed to access the view "/foo.jsp".
-
handlePrefixMapping
protected String handlePrefixMapping(String viewId, String prefix)
Return the normalized viewId according to the algorithm specified in 7.5.2 by stripping off any number of occurrences of the prefix mapping from the viewId.For example, both /faces/view.xhtml and /faces/faces/faces/view.xhtml would both return view.xhtml
-
handleSuffixMapping
protected String handleSuffixMapping(FacesContext context, String requestViewId)
Return the viewId with any non-standard suffix stripped off and replaced with the default suffix configured for the specified context.For example, an input parameter of "/foo.jsf" may return "/foo.jsp".
-
isViewExistent
public boolean isViewExistent(FacesContext facesContext, String viewId)
Check if a view exists- Parameters:
facesContext
-viewId
-- Returns:
-
calculateViewId
public String calculateViewId(FacesContext facesContext)
Calculates the view id from the given faces context by the following algorithm
- lookup the viewid from the request attribute "jakarta.servlet.include.path_info"
- if null lookup the value for viewid by
ExternalContext.getRequestPathInfo()
- if null lookup the value for viewid from the request attribute "jakarta.servlet.include.servlet_path"
- if null lookup the value for viewid by
ExternalContext.getRequestServletPath()
- if null throw a
FacesException
-
isViewProtected
public boolean isViewProtected(FacesContext context, String viewId)
-
-