ViewHandlingStrategy handles Facelets/PDL-based views.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static final classSimple no-op writer.
- 
Field SummaryFieldsFields inherited from class com.sun.faces.application.view.ViewHandlingStrategyassociate, webConfigFields inherited from class jakarta.faces.view.ViewDeclarationLanguageFACELETS_VIEW_DECLARATION_LANGUAGE_ID
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidbuildView(FacesContext ctx, UIViewRoot view) Take any actions specific to this VDL implementation to cause the argumentUIViewRootwhich must have been created via a call toViewDeclarationLanguage.createView(jakarta.faces.context.FacesContext, java.lang.String), to be populated with children.calculateResourceLibraryContracts(FacesContext context, String viewId) Return the list of resource library contracts that will be made available for use in the view specified by the argumentviewId.createComponent(FacesContext context, String taglibURI, String tagName, Map<String, Object> attributes) Create a component given aViewDeclarationLanguagespecific tag library URI and tag name.protected ResponseWritercreateResponseWriter(FacesContext context) createView(FacesContext ctx, String viewId) Create aUIViewRootfrom the VDL contained in the artifact referenced by the argumentviewId.getComponentMetadata(FacesContext context, Resource ccResource) Called by Application._createComponent(Resource).getId()Returns a non-null String that can be used to identify this view declaration language.protected StringgetResponseContentType(FacesContext context, String orig) protected StringgetResponseEncoding(FacesContext context, String orig) getScriptComponentResource(FacesContext context, Resource componentResource) Take implementation specific action to discover aResourcegiven the argumentcomponentResource.getStateManagementStrategy(FacesContext context, String viewId) For implementations that want to control the implementation of state saving and restoring, theStateManagementStrategyallows them to do so.getViewMetadata(FacesContext context, String viewId) Return a reference to the view metadata for the view represented by the argumentviewId, ornullif the metadata cannot be found.getViews(FacesContext context, String path, int maxDepth, ViewVisitOption... options) Return aStreampossibly lazily populated by walking the view tree rooted at a given initial path.getViews(FacesContext context, String path, ViewVisitOption... options) Return aStreampossibly lazily populated by walking the view tree rooted at a given initial path.protected voidhandleFaceletNotFound(FacesContext context, String viewId, String message) Handles the case where a Facelet cannot be found.protected voidhandleRenderException(FacesContext context, Exception e) Handles the case where rendering throws an Exception.booleanhandlesViewId(String viewId) protected voidInitialize the core Facelets runtime.protected voidInitialize mappings, during the first request.static booleanisBuildingMetadata(FacesContext context) voidrenderView(FacesContext ctx, UIViewRoot viewToRender) Render a view rooted at argumentview.restoreView(FacesContext context, String viewId) IfUIDebug.debugRequest(jakarta.faces.context.FacesContext)} istrue, simply return a new UIViewRoot(), otherwise, call the default logic.voidretargetAttachedObjects(FacesContext context, UIComponent topLevelComponent, List<AttachedObjectHandler> handlers) Assuming the component metadata for argumenttopLevelComponenthas been made available by an earlier call toViewDeclarationLanguage.getComponentMetadata(jakarta.faces.context.FacesContext, jakarta.faces.application.Resource), leverage the component metadata for the purpose of re-targeting attached objects from the top level composite component to the individualAttachedObjectTargetinstances inside the composite component.voidretargetMethodExpressions(FacesContext context, UIComponent topLevelComponent) Assuming the component metadata for argumenttopLevelComponenthas been made available by an earlier call toViewDeclarationLanguage.getComponentMetadata(jakarta.faces.context.FacesContext, jakarta.faces.application.Resource), leverage the component metadata for the purpose of re-targeting any method expressions from the top level component to the appropriate inner component.booleanviewExists(FacesContext context, String viewId) Tests whether a physical resource corresponding to the specified viewId exists.
- 
Field Details- 
IS_BUILDING_METADATA
- 
RESOURCE_LIBRARY_CONTRACT_DATA_STRUCTURE_KEY
 
- 
- 
Constructor Details- 
FaceletViewHandlingStrategypublic FaceletViewHandlingStrategy()
 
- 
- 
Method Details- 
isBuildingMetadata
- 
restoreViewIf UIDebug.debugRequest(jakarta.faces.context.FacesContext)} istrue, simply return a new UIViewRoot(), otherwise, call the default logic.- Overrides:
- restoreViewin class- ViewHandlingStrategy
- Parameters:
- context- the- FacesContextfor this request.
- viewId- the identifier for a previously rendered view.
- Returns:
- the restored view
- See Also:
 
- 
getViewMetadataDescription copied from class:ViewDeclarationLanguageReturn a reference to the view metadata for the view represented by the argument viewId, ornullif the metadata cannot be found. See section 7.7.2 "Default ViewDeclarationLanguage Implementation" of the Jakarta Faces Specification Document for the specification of the default implementation. Facelets implementation must return non-null.- Specified by:
- getViewMetadatain class- ViewDeclarationLanguage
- Parameters:
- context- The- FacesContextfor this request.
- viewId- the view id from which to extract the metadata
- Returns:
- the view metadata
 
- 
createViewDescription copied from class:ViewDeclarationLanguageCreate a UIViewRootfrom the VDL contained in the artifact referenced by the argumentviewId. See section 7.7.2"Default ViewDeclarationLanguage Implementation" of the Jakarta Faces Specification Document for the specification of the default implementation.- Overrides:
- createViewin class- ViewHandlingStrategy
- Parameters:
- ctx- the- FacesContextfor this request.
- viewId- the identifier of an artifact that contains the VDL syntax that describes this view.
- Returns:
- the newly created view root
- See Also:
 
- 
buildViewDescription copied from class:ViewDeclarationLanguageTake any actions specific to this VDL implementation to cause the argument UIViewRootwhich must have been created via a call toViewDeclarationLanguage.createView(jakarta.faces.context.FacesContext, java.lang.String), to be populated with children.The Facelets implementation must insure that markup comprising the view must be executed, with the UIComponentinstances in the view being encountered in the same depth-first order as in other lifecycle methods defined onUIComponent, and added to the view (but not rendered) during the traversal. The runtime must guarantee that the view must be fully populated before any of the following happen.- 
 The PhaseListener.afterPhase(jakarta.faces.event.PhaseEvent)method of anyPhaseListeners attached to the application is called
- 
 The UIViewRootphase listener installed viaUIViewRoot.setAfterPhaseListener(jakarta.el.MethodExpression)orUIViewRoot.addPhaseListener(jakarta.faces.event.PhaseListener)are called.
 If the rootis already populated with children, the view must still be re-built, but care must be taken to ensure that the existing components are correctly paired up with their VDL counterparts in the VDL page. Also, any system events that would normally be generated during the adding or removing of components from the view must be temporarily disabled during the creation of the view and then re-enabled when the view has been built.- Specified by:
- buildViewin class- ViewDeclarationLanguage
- Parameters:
- ctx- the- FacesContextfor this request
- view- the- UIViewRootto populate with children using techniques specific to this VDL implementation.
- Throws:
- IOException- if view cannot be built for any reason
- See Also:
 
- 
 
- 
renderViewDescription copied from class:ViewDeclarationLanguageRender a view rooted at argument view. See section 7.7.2 "Default ViewDeclarationLanguage Implementation" of the Jakarta Faces Specification Document for the specification of the default implementation.- Specified by:
- renderViewin class- ViewDeclarationLanguage
- Parameters:
- ctx- the- FacesContextfor this request.
- viewToRender- the- UIViewRootfrom an early call to- ViewDeclarationLanguage.createView(jakarta.faces.context.FacesContext, java.lang.String)or- ViewDeclarationLanguage.restoreView(jakarta.faces.context.FacesContext, java.lang.String).
- Throws:
- IOException- if the view cannot be rendered for any reason
- See Also:
 
- 
getStateManagementStrategyDescription copied from class:ViewDeclarationLanguageFor implementations that want to control the implementation of state saving and restoring, the StateManagementStrategyallows them to do so. Returningnullindicates that the implementation wishes the runtime to handle the state saving and restoring. Implementations that provide the VDL for Facelets for Jakarta Faces 2.0 and later must return non-nullfrom this method.- Specified by:
- getStateManagementStrategyin class- ViewDeclarationLanguage
- Parameters:
- context- the- FacesContextfor the current request.
- viewId- the view id.
- Returns:
- the strategy as specified above
 
- 
getComponentMetadataCalled by Application._createComponent(Resource). This method creates two temporary UIComponent instances to aid in the creation of the compcomp metadata. These instances no longer needed after the method returns and can be safely garbage collected. PENDING(): memory analysis should be done to verify there are no memory leaks as a result of this implementation. The instances are 1. tmp: a jakarta.faces.NamingContainer to serve as the temporary top level component 2. facetComponent: a jakarta.faces.Panel to serve as the parent UIComponent that is passed to Facelets so that the<cc:interface>section can be parsed and understood. Per the compcomp spec, tmp has the compcomp Resource stored in its attr set under the key Resource.COMPONENT_RESOURCE_KEY. tmp has the facetComponent added as its UIComponent.COMPOSITE_FACET_NAME facet.- Specified by:
- getComponentMetadatain class- ViewDeclarationLanguage
- Parameters:
- context- The- FacesContextfor this request.
- ccResource- The- Resourcethat represents the component.
- Returns:
- the component metadata
 
- 
getScriptComponentResourceDescription copied from class:ViewDeclarationLanguageTake implementation specific action to discover a Resourcegiven the argumentcomponentResource. See section 7.7.2 "Default ViewDeclarationLanguage Implementation" of the Jakarta Faces Specification Document for the specification of the default implementation. Jakarta Server Pages implementations must throwUnsupportedOperationException.- Specified by:
- getScriptComponentResourcein class- ViewDeclarationLanguage
- Parameters:
- context- The- FacesContextfor this request.
- componentResource- The- Resourcethat represents the component.
- Returns:
- the Resourcecorresponding to the argumentcomponentResource
- See Also:
 
- 
retargetAttachedObjectspublic void retargetAttachedObjects(FacesContext context, UIComponent topLevelComponent, List<AttachedObjectHandler> handlers) Description copied from class:ViewDeclarationLanguageAssuming the component metadata for argument topLevelComponenthas been made available by an earlier call toViewDeclarationLanguage.getComponentMetadata(jakarta.faces.context.FacesContext, jakarta.faces.application.Resource), leverage the component metadata for the purpose of re-targeting attached objects from the top level composite component to the individualAttachedObjectTargetinstances inside the composite component. This method must be called by theViewDeclarationLanguageimplementation when creating theUIComponenttree when a composite component usage is encountered.An algorithm semantically equivalent to the following must be implemented. - 
 Obtain the metadata for the composite component. Currently this entails getting the value of the UIComponent.BEANINFO_KEYcomponent attribute, which will be an instance ofBeanInfo. If the metadata cannot be found, log an error message and return.
- 
 Get the BeanDescriptorfrom theBeanInfo.
- 
 Get the value of the AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEYfrom theBeanDescriptor'sgetValue()method. This will be aList<. Let this be targetList.AttachedObjectTarget>
- 
 For each curHandler entry in the argument handlers- 
 Let forAttributeValue be the return from AttachedObjectHandler.getFor().
- 
 For each curTarget entry in targetList, the first of the following items that causes a match will take this action: For each UIComponentin the list returned from curTarget.getTargets(), call curHandler.applyAttachedObject(), passing theFacesContextand theUIComponent.and cause this inner loop to terminate. - 
 If curHandler is an instance of ActionSourceAttachedObjectHandlerand curTarget is an instance ofActionSourceAttachedObjectTarget, and curTarget.getName() is equal to curTargetName, consider it a match.
- 
 If curHandler is an instance of EditableValueHolderAttachedObjectHandlerand curTarget is an instance ofEditableValueHolderAttachedObjectTarget, and curTarget.getName() is equal to curTargetName, consider it a match.
- 
 If curHandler is an instance of ValueHolderAttachedObjectHandlerand curTarget is an instance ofValueHolderAttachedObjectTarget, and curTarget.getName() is equal to curTargetName, consider it a match.
- 
 If curHandler is an instance of BehaviorHolderAttachedObjectHandlerand curTarget is an instance ofBehaviorHolderAttachedObjectTarget, and either of the following conditions are true,- curHandler.getEventName() is not nulland is equal to curTargetName.
- curHandler.getEventName() is nulland curTarget.isDefaultEvent() istrue.
 consider it a match. 
- curHandler.getEventName() is not 
 
- 
 
 
- 
 
 The implementation must support retargeting attached objects from the top level compsite component to targets that are composite and non-composite components. An implementation is provided that will throw UnsupportedOperationException. A Faces implementation compliant with version 2.0 and beyond of the specification must override this method.- Overrides:
- retargetAttachedObjectsin class- ViewDeclarationLanguage
- Parameters:
- context- the FacesContext for this request.
- topLevelComponent- 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.
- handlers- the tag handlers for the attached objects
- See Also:
 
- 
 
- 
retargetMethodExpressionsDescription copied from class:ViewDeclarationLanguageAssuming the component metadata for argument topLevelComponenthas been made available by an earlier call toViewDeclarationLanguage.getComponentMetadata(jakarta.faces.context.FacesContext, jakarta.faces.application.Resource), leverage the component metadata for the purpose of re-targeting any method expressions from the top level component to the appropriate inner component. For each attribute that is aMethodExpression(as indicated by the presence of a "method-signature" attribute and the absence of a "type" attribute), the following action must be taken:- 
 Get the value of the targets attribute. If the value is a ValueExpressionevaluate it. If there is no targets attribute, let the name of the metadata element be the evaluated value of the targets attribute.
- 
 Interpret targets as a space (not tab) separated list of ids. For each entry in the list: - 
 Find the inner component of the topLevelComponent with the id equal to the current list entry. For discussion, this component is called target. If not found, log and error and continue to the next attribute. 
- 
 For discussion the declared name of the attribute is called name. 
- 
 In the attributes map of the topLevelComponent, look up the entry under the key name. Assume the result is a ValueExpression. For discussion, this is attributeValueExpression. If not found, log an error and continue to the next attribute.
- 
 If name is equal to the string "action", or "actionListener" without the quotes, assume target is an ActionSource.
- 
 If name is equal to the string "validator", or "valueChangeListener" without the quotes, assume target is an EditableValueHolder.
- 
 Call getExpressionString()on the attributeValueExpression and use that string to create aMethodExpressionof the appropriate signature for name.
- 
 If name is not equal to any of the previously listed strings, call getExpressionString()on the attributeValueExpression and use that string to create aMethodExpressionwhere the signature is created based on the value of the "method-signature" attribute of the<composite:attribute />tag.
- 
 Let the resultant MethodExpressionbe called attributeMethodExpression for discussion.
- 
 If name is equal to the string "action" without the quotes, call ActionSource.setActionExpression(jakarta.el.MethodExpression)on target, passing attributeMethodExpression.
- 
 If name is equal to the string "actionListener" without the quotes, call ActionSource.addActionListener(jakarta.faces.event.ActionListener)on target, passing attributeMethodExpression wrapped in aMethodExpressionActionListener.
- 
 If name is equal to the string "validator" without the quotes, call EditableValueHolder.addValidator(jakarta.faces.validator.Validator)on target, passing attributeMethodExpression wrapped in aMethodExpressionValidator.
- 
 If name is equal to the string "valueChangeListener" without the quotes, call EditableValueHolder.addValueChangeListener(jakarta.faces.event.ValueChangeListener)on target, passing attributeMethodExpression wrapped in aMethodExpressionValueChangeListener.
- 
 Otherwise, assume that the MethodExpressionshould be placed in the components attribute set. The runtme must create theMethodExpressioninstance based on the value of the "method-signature" attribute.
 
- 
 
 An implementation is provided that will throw UnsupportedOperationException. A Faces implementation compliant with version 2.0 and beyond of the specification must override this method.- Overrides:
- retargetMethodExpressionsin class- ViewDeclarationLanguage
- Parameters:
- context- the FacesContext for this request.
- topLevelComponent- 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.
 
- 
 
- 
createComponentpublic UIComponent createComponent(FacesContext context, String taglibURI, String tagName, Map<String, Object> attributes) Description copied from class:ViewDeclarationLanguageCreate a component given a ViewDeclarationLanguagespecific tag library URI and tag name. The runtime must support this method operating for the Facelets VDL. Other kinds ofViewDeclarationLanguagemay be supported but are not required to be supported. For backward compatibility with decoratedViewDeclrationLanguageimplementations that do not override this method, a default implementation is provided that returnsnull. However, any implementation that is compliant with the version of the specification in which this method was introduced must implement this method.- Overrides:
- createComponentin class- ViewDeclarationLanguage
- Parameters:
- context- the- FacesContextfor this request
- taglibURI- the fully qualified tag library URI that contains the component
- tagName- the name of the tag within that library that exposes the component
- attributes- any name=value pairs that would otherwise have been given on the markup that would cause the creation of this component or- nullif no attributes need be given.
- Returns:
- the newly created component
 
- 
calculateResourceLibraryContractsDescription copied from class:ViewDeclarationLanguageReturn the list of resource library contracts that will be made available for use in the view specified by the argument viewId. If no match is found, return an empty list. See section 7.7.2 "Default ViewDeclarationLanguage Implementation" of the Jakarta Faces Specification Document for the specification of the default implementation. For backward compatibility with prior implementations, an implementation is provided that returnsnull, but any implementation compliant with the version of the specification in which this method was introduced must implement it as specified in section 7.7.2 "Default ViewDeclarationLanguage Implementation" of the Jakarta Faces Specification Document.- Overrides:
- calculateResourceLibraryContractsin class- ViewDeclarationLanguage
- Parameters:
- context- the- FacesContextfor this request
- viewId- the view id for which the applicable resource library contracts should be calculated.
- Returns:
- the calculated list of resource library contract names
 
- 
viewExistsDescription copied from class:ViewDeclarationLanguageTests whether a physical resource corresponding to the specified viewId exists. The default implementation uses ResourceHandler.createViewResource(jakarta.faces.context.FacesContext, java.lang.String)to locate the physical resource.- Overrides:
- viewExistsin class- ViewDeclarationLanguage
- Parameters:
- context- The- FacesContextfor this request.
- viewId- the view id to test
- Returns:
- the result as specified above
 
- 
getViewsDescription copied from class:ViewDeclarationLanguageReturn a Streampossibly lazily populated by walking the view tree rooted at a given initial path. The view tree is traversed breadth-first, 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 resource tree.getViewResources(facesContext, start, Integer.MAX_VALUE, options) - Overrides:
- getViewsin class- ViewDeclarationLanguage
- Parameters:
- context- The- FacesContextfor this request.
- path- The initial path from which to start looking for views
- options- The options to influence the traversal. See- ViewVisitOptionfor details on those.
- Returns:
- the Streamof view ids
 
- 
getViewspublic Stream<String> getViews(FacesContext context, String path, int maxDepth, ViewVisitOption... options) Description copied from class:ViewDeclarationLanguageReturn a Streampossibly lazily populated by walking the view tree rooted at a given initial path. The view tree is traversed breadth-first, the elements in the stream are logical view ids.The maxDepthparameter is the maximum depth of directory levels to visit beyond 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.- Overrides:
- getViewsin class- ViewDeclarationLanguage
- Parameters:
- context- The- FacesContextfor this request.
- path- The initial path from which to start looking for views
- maxDepth- The absolute maximum depth of nested directories to visit counted from the root (- /).
- options- The options to influence the traversal. See- ViewVisitOptionfor details on those.
- Returns:
- the Streamof view ids
 
- 
handlesViewId- Specified by:
- handlesViewIdin class- ViewHandlingStrategy
- Parameters:
- viewId- the view ID to check
- Returns:
- trueif assuming a default configuration and the view ID's extension in- ViewHandler.FACELETS_SUFFIX_PARAM_NAMEOtherwise try to match the view ID based on the configured extensions and prefixes in- ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME
- See Also:
 
- 
getIdDescription copied from class:ViewDeclarationLanguageReturns a non-null String that can be used to identify this view declaration language. The default implementation returns the fully qualified class name of the view declaration language implementation. Subclasses may override to provide a more meaningful id. - Overrides:
- getIdin class- ViewDeclarationLanguage
- Returns:
- the id of this view declaration language
 
- 
initializeprotected void initialize()Initialize the core Facelets runtime.
- 
initializeMappingsprotected void initializeMappings()Initialize mappings, during the first request.
- 
createResponseWriter- Parameters:
- context- the- FacesContextfor the current request
- Returns:
- a ResponseWriterfor processing the request
- Throws:
- IOException- if the writer cannot be created
 
- 
handleRenderExceptionHandles the case where rendering throws an Exception.- Parameters:
- context- the- FacesContextfor the current request
- e- the caught Exception
- Throws:
- IOException- if the custom debug content cannot be written
 
- 
handleFaceletNotFoundprotected void handleFaceletNotFound(FacesContext context, String viewId, String message) throws IOException Handles the case where a Facelet cannot be found.- Parameters:
- context- the- FacesContextfor the current request
- viewId- the view ID that was to be mapped to a Facelet
- message- optional message to include in the 404
- Throws:
- IOException- if an error occurs sending the 404 to the client
 
- 
getResponseEncoding- Parameters:
- context- the- FacesContextfor the current request
- orig- the original encoding
- Returns:
- the encoding to be used for this response
 
- 
getResponseContentType- Parameters:
- context- the- FacesContextfor the current request
- orig- the original contentType
- Returns:
- the content type to be used for this response
 
 
-