Home » Mojarra-2.0.1 » javax.faces.view » [javadoc | source]
javax.faces.view
abstract public class: ViewDeclarationLanguage [javadoc | source]
java.lang.Object
   javax.faces.view.ViewDeclarationLanguage

The contract that a view declaration language must implement to interact with the JSF runtime. An implementation of this class must be thread-safe.

Instances of this class are application scoped and must be obtained from the ViewDeclarationLanguageFactory .

Method from javax.faces.view.ViewDeclarationLanguage Summary:
buildView,   createView,   getComponentMetadata,   getScriptComponentResource,   getStateManagementStrategy,   getViewMetadata,   renderView,   restoreView,   retargetAttachedObjects,   retargetMethodExpressions
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.faces.view.ViewDeclarationLanguage Detail:
 abstract public  void buildView(FacesContext context,
    UIViewRoot root) throws IOException
 abstract public UIViewRoot createView(FacesContext context,
    String viewId)

    Create a UIViewRoot from the VDL contained in the artifact referenced by the argument viewId. See section JSF.7.6.2 for the specification of the default implementation.

 abstract public BeanInfo getComponentMetadata(FacesContext context,
    Resource componentResource)

    Return a reference to the component metadata for the composite component represented by the argument componentResource, or null if the metadata cannot be found. See section JSF.7.6.2 for the specification of the default implementation. JSP implementations must throw UnsupportedOperationException.

 abstract public Resource getScriptComponentResource(FacesContext context,
    Resource componentResource)

    Take implementation specific action to discover a Resource given the argument componentResource. See section JSF.7.6.2 for the specification of the default implementation. JSP implementations must throw UnsupportedOperationException.

 abstract public StateManagementStrategy getStateManagementStrategy(FacesContext context,
    String viewId)

    For implementations that want to control the implementation of state saving and restoring, the StateManagementStrategy allows them to do so. Returning null indicates 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-null from this method.

 abstract public ViewMetadata getViewMetadata(FacesContext context,
    String viewId)

    Return a reference to the view metadata for the view represented by the argument viewId, or null if the metadata cannot be found. See section JSF.7.6.2 for the specification of the default implementation. Facelets for JSF 2 implementation must return non-null. JSP implementations must return null.

 abstract public  void renderView(FacesContext context,
    UIViewRoot view) throws IOException

    Render a view rooted at argumentview. See section JSF.7.6.2 for the specification of the default implementation.

 abstract public UIViewRoot restoreView(FacesContext context,
    String viewId)

    Restore a UIViewRoot from a previously created view. See section JSF.7.6.2 for the specification of the default implementation.

 public  void retargetAttachedObjects(FacesContext context,
    UIComponent topLevelComponent,
    List<AttachedObjectHandler> handlers) 

    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. This method must be called by the ViewDeclarationLanguage implementation when creating the UIComponent tree when a composite component usage is encountered.

    An algorithm semantically equivalent to the following must be implemented.

    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.

 public  void retargetMethodExpressions(FacesContext context,
    UIComponent topLevelComponent) 

    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. For each attribute that is a MethodExpression (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 ValueExpression evaluate 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 javax.faces.component.ActionSource2 .

      • If name is equal to the string "validator", or "valueChangeListener" without the quotes, assume target is an javax.faces.component.EditableValueHolder .

      • Call getExpressionString() on the attributeValueExpression and use that string to create a MethodExpression of 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 a MethodExpression where the signature is created based on the value of the "method-signature" attribute of the <composite:attribute /> tag.

      • Let the resultant MethodExpression be called attributeMethodExpression for discussion.

      • If name is equal to the string "action" without the quotes, call javax.faces.component.ActionSource2#setActionExpression on target, passing attributeMethodExpression.

      • If name is equal to the string "actionListener" without the quotes, call javax.faces.component.ActionSource#addActionListener on target, passing attributeMethodExpression wrapped in a javax.faces.event.MethodExpressionActionListener .

      • If name is equal to the string "validator" without the quotes, call javax.faces.component.EditableValueHolder#addValidator on target, passing attributeMethodExpression wrapped in a javax.faces.validator.MethodExpressionValidator .

      • If name is equal to the string "valueChangeListener" without the quotes, call javax.faces.component.EditableValueHolder#addValueChangeListener on target, passing attributeMethodExpression wrapped in a javax.faces.event.MethodExpressionValueChangeListener .

      • Otherwise, assume that the MethodExpression should be placed in the components attribute set. The runtme must create the MethodExpression instance 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.