Class ViewDeclarationLanguageWrapper
- All Implemented Interfaces:
FacesWrapper<ViewDeclarationLanguage>
Provides a simple implementation of
ViewDeclarationLanguage that can
be subclassed by developers wishing to provide specialized behavior
to an existing ViewDeclarationLanguage instance. The default
implementation of all methods is to call through to the wrapped
ViewDeclarationLanguage instance.
Usage: extend this class and override
getWrapped() to
return the instance being wrapping.
- Since:
- 2.2
-
Field Summary
Fields inherited from class javax.faces.view.ViewDeclarationLanguage
FACELETS_VIEW_DECLARATION_LANGUAGE_ID, JSP_VIEW_DECLARATION_LANGUAGE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildView(FacesContext context, UIViewRoot root) Take any actions specific to this VDL implementation to cause the argumentUIViewRootwhich must have been created via a call toViewDeclarationLanguage.createView(javax.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.createView(FacesContext context, String viewId) Create aUIViewRootfrom the VDL contained in the artifact referenced by the argumentviewId.getComponentMetadata(FacesContext context, Resource componentResource) Return a reference to the component metadata for the composite component represented by the argumentcomponentResource, ornullif the metadata cannot be found.getId()Returns a non-null String that can be used to identify this view declaration language.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.abstract ViewDeclarationLanguageA class that implements this interface uses this method to return an instance of the class being wrapped.voidrenderView(FacesContext context, UIViewRoot view) Render a view rooted at argumentview.restoreView(FacesContext context, String viewId) Restore aUIViewRootfrom a previously created view.voidretargetAttachedObjects(FacesContext context, UIComponent topLevelComponent, List<AttachedObjectHandler> handlers) Assuming the component metadata for argumenttopLevelComponenthas been made available by an earlier call toViewDeclarationLanguage.getComponentMetadata(javax.faces.context.FacesContext, javax.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(javax.faces.context.FacesContext, javax.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.
-
Constructor Details
-
ViewDeclarationLanguageWrapper
public ViewDeclarationLanguageWrapper()
-
-
Method Details
-
getWrapped
Description copied from interface:FacesWrapperA class that implements this interface uses this method to return an instance of the class being wrapped.
- Specified by:
getWrappedin interfaceFacesWrapper<ViewDeclarationLanguage>- Returns:
- the wrapped
ViewDeclarationLanguageinstance - See Also:
-
getId
Description 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 classViewDeclarationLanguage
-
retargetAttachedObjects
public 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(javax.faces.context.FacesContext, javax.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
handlersLet 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
ActionSource2AttachedObjectHandlerand curTarget is an instance ofActionSource2AttachedObjectTarget, 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 classViewDeclarationLanguage- 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.
-
retargetMethodExpressions
Description copied from class:ViewDeclarationLanguageAssuming the component metadata for argument
topLevelComponenthas been made available by an earlier call toViewDeclarationLanguage.getComponentMetadata(javax.faces.context.FacesContext, javax.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
ActionSource2.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
ActionSource2.setActionExpression(javax.el.MethodExpression)on target, passing attributeMethodExpression.If name is equal to the string "actionListener" without the quotes, call
ActionSource.addActionListener(javax.faces.event.ActionListener)on target, passing attributeMethodExpression wrapped in aMethodExpressionActionListener.If name is equal to the string "validator" without the quotes, call
EditableValueHolder.addValidator(javax.faces.validator.Validator)on target, passing attributeMethodExpression wrapped in aMethodExpressionValidator.If name is equal to the string "valueChangeListener" without the quotes, call
EditableValueHolder.addValueChangeListener(javax.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 classViewDeclarationLanguage- 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.
-
viewExists
Description copied from class:ViewDeclarationLanguageTests whether a physical resource corresponding to the specified viewId exists.
The default implementation uses
ResourceHandler.createViewResource(javax.faces.context.FacesContext, java.lang.String)to locate the physical resource.- Overrides:
viewExistsin classViewDeclarationLanguage- Parameters:
context- TheFacesContextfor this request.viewId- the view id to test
-
buildView
Description 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(javax.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(javax.faces.event.PhaseEvent)method of anyPhaseListeners attached to the application is calledThe
UIViewRootphase listener installed viaUIViewRoot.setAfterPhaseListener(javax.el.MethodExpression)orUIViewRoot.addPhaseListener(javax.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 classViewDeclarationLanguage- Parameters:
context- theFacesContextfor this requestroot- theUIViewRootto populate with children using techniques specific to this VDL implementation.- Throws:
IOException
-
calculateResourceLibraryContracts
Description 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 JSF.7.7.2 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 JSF.7.7.2.- Overrides:
calculateResourceLibraryContractsin classViewDeclarationLanguage- Parameters:
context- theFacesContextfor this requestviewId- the view id for which the applicable resource library contracts should be calculated.
-
createView
Description copied from class:ViewDeclarationLanguageCreate a
UIViewRootfrom the VDL contained in the artifact referenced by the argumentviewId. See section JSF.7.7.2 for the specification of the default implementation.- Specified by:
createViewin classViewDeclarationLanguage- Parameters:
context- theFacesContextfor this request.viewId- the identifier of an artifact that contains the VDL syntax that describes this view.
-
createComponent
public 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 classViewDeclarationLanguage- Parameters:
context- theFacesContextfor this requesttaglibURI- the fully qualified tag library URI that contains the componenttagName- the name of the tag within that library that exposes the componentattributes- any name=value pairs that would otherwise have been given on the markup that would cause the creation of this component ornullif no attributes need be given.
-
getComponentMetadata
Description copied from class:ViewDeclarationLanguageReturn a reference to the component metadata for the composite component represented by the argument
componentResource, ornullif the metadata cannot be found. See section JSF.7.7.2 for the specification of the default implementation. JSP implementations must throwUnsupportedOperationException.- Specified by:
getComponentMetadatain classViewDeclarationLanguage- Parameters:
context- TheFacesContextfor this request.componentResource- TheResourcethat represents the component.
-
getScriptComponentResource
Description copied from class:ViewDeclarationLanguageTake implementation specific action to discover a
Resourcegiven the argumentcomponentResource. See section JSF.7.7.2 for the specification of the default implementation. JSP implementations must throwUnsupportedOperationException.- Specified by:
getScriptComponentResourcein classViewDeclarationLanguage- Parameters:
context- TheFacesContextfor this request.componentResource- TheResourcethat represents the component.
-
getStateManagementStrategy
Description 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 JSF 2.0 and later must return non-nullfrom this method.- Specified by:
getStateManagementStrategyin classViewDeclarationLanguage
-
getViewMetadata
Description 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 JSF.7.7.2 for the specification of the default implementation. Facelets for JSF 2 implementation must return non-null. JSP implementations must returnnull.- Specified by:
getViewMetadatain classViewDeclarationLanguage- Parameters:
context- TheFacesContextfor this request.viewId- the view id from whith to extract the metadata
-
renderView
Description copied from class:ViewDeclarationLanguageRender a view rooted at argument
view. See section JSF.7.7.2 for the specification of the default implementation.- Specified by:
renderViewin classViewDeclarationLanguage- Parameters:
context- theFacesContextfor this request.view- theUIViewRootfrom an early call toViewDeclarationLanguage.createView(javax.faces.context.FacesContext, java.lang.String)orViewDeclarationLanguage.restoreView(javax.faces.context.FacesContext, java.lang.String).- Throws:
IOException
-
restoreView
Description copied from class:ViewDeclarationLanguageRestore a
UIViewRootfrom a previously created view. See section JSF.7.7.2 for the specification of the default implementation.- Specified by:
restoreViewin classViewDeclarationLanguage- Parameters:
context- theFacesContextfor this request.viewId- the identifier for a previously rendered view.
-