Top Description Inners Fields Constructors Methods
com.sun.faces.application.view

public Class FaceletViewHandlingStrategy

extends ViewHandlingStrategy
Class Inheritance
Static Imports
com.sun.faces.RIConstants.DYNAMIC_COMPONENT, .RIConstants.FACELETS_ENCODING_KEY, .RIConstants.FLOW_DEFINITION_ID_SUFFIX, com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsBufferSize, .WebConfiguration.WebContextInitParameter.FaceletsViewMappings, .WebConfiguration.WebContextInitParameter.StateSavingMethod, com.sun.faces.context.StateContext.getStateContext, com.sun.faces.facelets.tag.ui.UIDebug.debugRequest, com.sun.faces.renderkit.RenderKitUtils.getResponseStateManager, com.sun.faces.util.ComponentStruct.ADD, .ComponentStruct.REMOVE, .RequestStateManager.FACELET_FACTORY, .Util.getDOCTYPEFromFacesContextAttributes, .Util.getXMLDECLFromFacesContextAttributes, .Util.isEmpty, .Util.isViewIdExactMappedToFacesServlet, .Util.isViewPopulated, .Util.notNull, .Util.saveDOCTYPEToFacesContextAttributes, .Util.saveXMLDECLToFacesContextAttributes, .Util.setViewPopulated, .Util.split, jakarta.faces.FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY, jakarta.faces.application.ProjectStage.Development, .Resource.COMPONENT_RESOURCE_KEY, .StateManager.IS_BUILDING_INITIAL_STATE, .StateManager.STATE_SAVING_METHOD_SERVER, .ViewHandler.DEFAULT_FACELETS_SUFFIX, .ViewVisitOption.RETURN_AS_MINIMAL_IMPLICIT_OUTCOME, jakarta.faces.component.UIComponent.BEANINFO_KEY, .UIComponent.COMPOSITE_FACET_NAME, .UIComponent.VIEW_LOCATION_KEY, .UIViewRoot.COMPONENT_TYPE, jakarta.faces.view.AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY, jakarta.faces.view.facelets.FaceletContext.FACELET_CONTEXT_KEY, jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND, java.lang.Boolean.TRUE, java.util.Arrays.stream, .Collections.emptyList, java.util.logging.Level.FINE, .Level.FINEST, .Level.SEVERE, .Level.WARNING

This ViewHandlingStrategy handles Facelets/PDL-based views.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
FaceletViewHandlingStrategy.CompCompInterfaceMethodMetadata

Utility class to encapsulate the ValueExpression evaluation of the various MethodExpression composite component properties.

private static class
FaceletViewHandlingStrategy.MethodMetadataIterator

Provides iteration services over a composite component's MethodExpression-enabled PropertyDescriptors.

private static interface
FaceletViewHandlingStrategy.MethodRetargetHandler

Implementations of this interface provide the strategy to properly retarget a method expression for a particular attribute.

private static class
FaceletViewHandlingStrategy.MethodRetargetHandlerManager

Managed the MethodRetargetHandler implementations for the current MethodExpression enabled component attributes:

  • action
  • actionListener
  • validator
  • valueChangeListener
protected static class

Field Summary

Modifier and TypeField and Description
private Map<String, List<String>>
private String[]
private DefaultFaceletFactory
public static final String
private static final Logger
private Cache<Resource, BeanInfo>
private String[]
public static final String
private int
private final FaceletViewHandlingStrategy.MethodRetargetHandlerManager
private ViewDeclarationLanguageFactory
Inherited from com.sun.faces.application.view.ViewHandlingStrategy:
associatewebConfig

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
buildView(FacesContext
the FacesContext for this request
ctx
,
UIViewRoot
the UIViewRoot to populate with children using techniques specific to this VDL implementation.
view
)

Implements abstract jakarta.faces.view.ViewDeclarationLanguage.buildView.

Take any actions specific to this VDL implementation to cause the argument UIViewRoot which must have been created via a call to createView, to be populated with children.

public List<String>
calculateResourceLibraryContracts(FacesContext
the FacesContext for this request
context
,
String
the view id for which the applicable resource library contracts should be calculated.
viewId
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.calculateResourceLibraryContracts.

Return the list of resource library contracts that will be made available for use in the view specified by the argument viewId.

public UIComponent
createComponent(FacesContext
the FacesContext for this request
context
,
String
the fully qualified tag library URI that contains the component
taglibURI
,
String
the name of the tag within that library that exposes the component
tagName
,
Map<String, Object>
any name=value pairs that would otherwise have been given on the markup that would cause the creation of this component or null if no attributes need be given.
attributes
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.createComponent.

Create a component given a ViewDeclarationLanguage specific tag library URI and tag name.

private BeanInfo
protected ResponseWriter

Returns:

a ResponseWriter for processing the request
createResponseWriter
(FacesContext
the FacesContext for the current request
context
)

public UIViewRoot
createView(FacesContext
the FacesContext for this request.
ctx
,
String
the identifier of an artifact that contains the VDL syntax that describes this view.
viewId
)

Overrides com.sun.faces.application.view.ViewHandlingStrategy.createView.

Create a UIViewRoot from the VDL contained in the artifact referenced by the argument viewId.

public BeanInfo
getComponentMetadata(FacesContext
The FacesContext for this request.
context
,
Resource
The Resource that represents the component.
ccResource
)

Implements abstract jakarta.faces.view.ViewDeclarationLanguage.getComponentMetadata.

Called by Application._createComponent(Resource).

private String
private String
private String
private DefaultFaceletFactory

Returns:

the default faceletFactorys
getFaceletFactory
()

Gets and if needed initializes the faceletFactory

public String
getId()

Overrides jakarta.faces.view.ViewDeclarationLanguage.getId.

Returns a non-null String that can be used to identify this view declaration language.

private String
protected String

Returns:

the content type to be used for this response
getResponseContentType
(FacesContext
the FacesContext for the current request
context
,
String
the original contentType
orig
)

public Resource
getScriptComponentResource(FacesContext
The FacesContext for this request.
context
,
Resource
The Resource that represents the component.
componentResource
)

Implements abstract jakarta.faces.view.ViewDeclarationLanguage.getScriptComponentResource.

Take implementation specific action to discover a Resource given the argument componentResource.

private HttpSession

Returns:

the session, or null if we are not using server state saving.
getSession
(FacesContext
the Faces context.
context
)

Get a session (if we are using server state saving).

public StateManagementStrategy
getStateManagementStrategy(FacesContext
the FacesContext for the current request.
context
,
String
the view id.
viewId
)

Implements abstract jakarta.faces.view.ViewDeclarationLanguage.getStateManagementStrategy.

For implementations that want to control the implementation of state saving and restoring, the StateManagementStrategy allows them to do so.

public ViewMetadata
getViewMetadata(FacesContext
The FacesContext for this request.
context
,
String
the view id from which to extract the metadata
viewId
)

Implements abstract jakarta.faces.view.ViewDeclarationLanguage.getViewMetadata.

Return a reference to the view metadata for the view represented by the argument viewId, or null if the metadata cannot be found.

public Stream<String>
getViews(FacesContext
The FacesContext for this request.
context
,
String
The initial path from which to start looking for views
path
,
ViewVisitOption...
The options to influence the traversal. See ViewVisitOption for details on those.
options
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.getViews.

Return a Stream possibly lazily populated by walking the view tree rooted at a given initial path.

public Stream<String>
getViews(FacesContext
The FacesContext for this request.
context
,
String
The initial path from which to start looking for views
path
,
int
The absolute maximum depth of nested directories to visit counted from the root (/).
maxDepth
,
ViewVisitOption...
The options to influence the traversal. See ViewVisitOption for details on those.
options
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.getViews.

Return a Stream possibly lazily populated by walking the view tree rooted at a given initial path.

protected void
handleFaceletNotFound(FacesContext
the FacesContext for the current request
context
,
String
the view ID that was to be mapped to a Facelet
viewId
,
String
optional message to include in the 404
message
)

Handles the case where a Facelet cannot be found.

protected void
handleRenderException(FacesContext
the FacesContext for the current request
context
,
Exception
the caught Exception
e
)

Handles the case where rendering throws an Exception.

private boolean
public boolean

Returns:

true if assuming a default configuration and the view ID's extension in ViewHandler#FACELETS_SUFFIX_PARAM_NAME Otherwise try to match the view ID based on the configured extensions and prefixes in ViewHandler#FACELETS_VIEW_MAPPINGS_PARAM_NAME
handlesViewId
(String
the view ID to check
viewId
)

Implements abstract com.sun.faces.application.view.ViewHandlingStrategy.handlesViewId.

protected void
initialize()

Initialize the core Facelets runtime.

protected void
initializeMappings()

Initialize mappings, during the first request.

public static boolean
private boolean
private boolean

Returns:

true if we are, false otherwise.
isServerStateSaving
()

Are we saving state server side?

private boolean
isStateless(FacesContext context, String viewId)

private UIComponent
locateComponentByClientId(final FacesContext
the Faces context.
context
,
final UIComponent parent, final String
the client id of the component to find.
clientId
,
final boolean dynamic)

Find the given component in the component tree.

private Stream<String>

Returns:

The stream with views, possibly mapped if needed
mapIfNeeded
(Stream<String>
The stream of views to potentially map
views
,
ViewVisitOption...
Options telling if and if so how to map
options
)

Maps the element in the passed in stream of views according to the given options.

private void
private void
markInitialState(final UIComponent component)

private void
markInitialStateIfNotMarked(UIComponent component)

Mark the initial state if not already marked.

private void
reapplyDynamicActions(FacesContext
the Faces context.
context
)

Reapply the dynamic actions after Facelets reapply.

private void
reapplyDynamicAdd(FacesContext
the Faces context.
context
,
ComponentStruct
the component struct.
struct
)

Reapply the dynamic add after Facelets reapply.

private void
reapplyDynamicRemove(FacesContext
the Faces context.
context
,
ComponentStruct
the component struct.
struct
)

Reapply the dynamic remove after Facelets reapply.

public void
renderView(FacesContext
the FacesContext for this request.
ctx
,
UIViewRoot
the UIViewRoot from an early call to createView or restoreView.
viewToRender
)

Implements abstract jakarta.faces.view.ViewDeclarationLanguage.renderView.

Render a view rooted at argumentview.

public UIViewRoot
restoreView(FacesContext
the FacesContext for this request.
context
,
String
the identifier for a previously rendered view.
viewId
)

Overrides com.sun.faces.application.view.ViewHandlingStrategy.restoreView.

If UIDebug#debugRequest(jakarta.faces.context.FacesContext)} is true, simply return a new UIViewRoot(), otherwise, call the default logic.

public void
retargetAttachedObjects(FacesContext
the FacesContext for this request.
context
,
UIComponent
The UIComponent in the view to which the attached objects must be attached. This UIComponent must have its component metadata already associated and available from via the JavaBeans API.
topLevelComponent
,
List<AttachedObjectHandler>
the tag handlers for the attached objects
handlers
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.retargetAttachedObjects.

Assuming the component metadata for argument topLevelComponent has been made available by an earlier call to ViewDeclarationLanguage#getComponentMetadata, leverage the component metadata for the purpose of re-targeting attached objects from the top level composite component to the individual AttachedObjectTarget instances inside the composite component.

private void
public void
retargetMethodExpressions(FacesContext
the FacesContext for this request.
context
,
UIComponent
The UIComponent in the view to which the attached objects must be attached. This UIComponent must have its component metadata already associated and available from via the JavaBeans API.
topLevelComponent
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.retargetMethodExpressions.

Assuming the component metadata for argument topLevelComponent has been made available by an earlier call to ViewDeclarationLanguage#getComponentMetadata, leverage the component metadata for the purpose of re-targeting any method expressions from the top level component to the appropriate inner component.

private boolean
private void
private void
private String
public boolean
viewExists(FacesContext
The FacesContext for this request.
context
,
String
the view id to test
viewId
)

Overrides jakarta.faces.view.ViewDeclarationLanguage.viewExists.

Tests whether a physical resource corresponding to the specified viewId exists.