Top Description Fields Constructors Methods
javax.faces.view.facelets

public Class ComponentHandler

extends DelegatingMetaTagHandler
Class Inheritance
Known Direct Subclasses
com.sun.faces.facelets.tag.composite.RenderFacetHandler, com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler, com.sun.faces.facelets.tag.jsf.PassThroughElementComponentHandler, com.sun.faces.facelets.tag.jsf.core.VerbatimHandler, com.sun.faces.facelets.tag.jsf.html.HtmlComponentHandler, com.sun.faces.facelets.tag.jsf.html.ScriptResourceHandler, com.sun.faces.facelets.tag.jsf.html.StylesheetResourceHandler, com.sun.faces.facelets.tag.ui.ComponentRefHandler, com.sun.faces.facelets.tag.ui.RepeatHandler
Imports
javax.faces.component.UIComponent

Public base class for markup element instances that map to UIComponent instances in the view.

Instances of this class are created and passed to TagHandlerDelegateFactory#createComponentHandlerDelegate when a tag corresponding to this particular component is encountered in a Facelet view. A custom tag handler for a component, converter, validator, or behavior must extend from this class. In this way, this instance acts as a delegate for the implementation private tag handler. Such a subclass may choose to override as many or as few methods from this base class as desired. If the subclass wants to completely override the action of the implementation specific tag for which this component is the delegate, it must override the apply() method and make it take the following actions, in this order. These actions must only happen the first time this facelet is applied for each user. Subsequent applications must take no action.

  1. The UIComponent represented by this element is created with the appropriate Application.createComponent() method.

  2. Each attribute specified in the markup is correctly applied to the component instance, as specified in the VDLDocs for this element.

  3. If project stage is javax.faces.application.ProjectStage#Development, Put the javax.faces.view.Location for this element into the component attribute Map under the key given by the value of the symbolic constant javax.faces.component.UIComponent#VIEW_LOCATION_KEY.

  4. Set the id of the component. If the id is specified manually by the page author, that value must be set as the id. Otherwise, the closest ancestor component that is an instance of javax.faces.component.UniqueIdVendor must be located and its javax.faces.component.UniqueIdVendor#createUniqueId method must be called to derive the id. If no such instance can be found, call javax.faces.component.UIViewRoot#createUniqueId to derive the id.

  5. The rendererType property of the component is set properly.

  6. onComponentCreated is called.

  7. UIComponent#pushComponentToEL is called on the newly created component.

  8. The next handler in the facelet chain is applied. This will cause the component to be populated with children.

  9. The component is added to its parent in the view.

  10. UIComponent#popComponentFromEL is called on the newly created component.

  11. Call UIComponent#markInitialState.

A common use case for extending this class is to gain access to the process by which the Facelets runtime creates component instances corresponding to markup in a Facelets view. These three methods are useful in such cases.

  • To control the instantiation of the UIComponent instance, subclasses may override createComponent. If this method is not overridden, the tag handler for which this instance is the delegate will take the necessary action to instantiate the UIComponent.

  • To be notified of creation of the UIComponentinstance, subclasses may override onComponentCreated.

  • To be notified that the freshly created UIComponent instance has been populated with children as a result of execution of child tag handlers, subclasses may override onComponentPopulated.

Since
2.0

Field Summary

Modifier and TypeField and Description
private ComponentConfig
private TagHandlerDelegate
Inherited from javax.faces.view.facelets.DelegatingMetaTagHandler:
delegateFactory

Constructor Summary

AccessConstructor and Description
public
ComponentHandler(ComponentConfig
the configuration for this handler.
config
)

Leverage the TagHandlerDelegateFactory provided by the implementation to create an instance of TagHandlerDelegate designed for use with ComponentHandler.

Method Summary

Modifier and TypeMethod and Description
public UIComponent

Returns:

the newly created UIComponent
createComponent
(FaceletContext
the FaceletContext for this view execution
ctx
)

Subclasses that wish to take over the task of instantiating the UIComponent instance corresponding to this tag handler my override this method to do so.

public ComponentConfig
protected TagHandlerDelegate
public static boolean

Returns:

true if and only if the argument is not null and the component is new during this run of the lifecycle.
isNew
(UIComponent
the component you wish to modify
component
)

Determine if the passed component is not null and if it's new to the tree.

public void
onComponentCreated(FaceletContext
the FaceletContext for this view execution
ctx
,
UIComponent
the UIComponent that has just been created.
c
,
UIComponent
the parent UIComponent of the component represented by this element instance.
parent
)

This method is guaranteed to be called after the component has been created but before it has been populated with children.

public void
onComponentPopulated(FaceletContext
the FaceletContext for this view execution
ctx
,
UIComponent
the UIComponent that has just been populated with children.
c
,
UIComponent
the parent UIComponent of the component represented by this element instance.
parent
)

This method is guaranteed to be called after the component has been populated with children.

Inherited from javax.faces.view.facelets.DelegatingMetaTagHandler:
applyapplyNextHandlercreateMetaRulesetgetBindinggetTaggetTagAttributegetTagIdisDisabledsetAttributes

Field Detail

componentConfigback to summary
private ComponentConfig componentConfig
helperback to summary
private TagHandlerDelegate helper

Constructor Detail

ComponentHandlerback to summary
public ComponentHandler(ComponentConfig config)

Leverage the TagHandlerDelegateFactory provided by the implementation to create an instance of TagHandlerDelegate designed for use with ComponentHandler.

Parameters
config:ComponentConfig

the configuration for this handler.

Since
2.0

Method Detail

createComponentback to summary
public UIComponent createComponent(FaceletContext ctx)

Subclasses that wish to take over the task of instantiating the UIComponent instance corresponding to this tag handler my override this method to do so. A null return from this method will cause the TagHandlerDelegate for instance to create the component instead.

Parameters
ctx:FaceletContext

the FaceletContext for this view execution

Returns:UIComponent

the newly created UIComponent

Since
2.2
getComponentConfigback to summary
public ComponentConfig getComponentConfig()
getTagHandlerDelegateback to summary
protected TagHandlerDelegate getTagHandlerDelegate()

Implements abstract javax.faces.view.facelets.DelegatingMetaTagHandler.getTagHandlerDelegate.

Doc from javax.faces.view.facelets.DelegatingMetaTagHandler.getTagHandlerDelegate.

Get the tag handler delegate.

Code that extends from DelegatingMetaTagHandler (directly or indirectly, as through extending ComponentHandler) must take care to decorate, not replace, the TagHandlerDelegate instance returned by this method. Failure to do so may produce unexpected results.

Returns:TagHandlerDelegate

the tag handler delegate.

Annotations
@Override
isNewback to summary
public static boolean isNew(UIComponent component)

Determine if the passed component is not null and if it's new to the tree. This operation can be used for determining if attributes should be wired to the component.

Parameters
component:UIComponent

the component you wish to modify

Returns:boolean

true if and only if the argument is not null and the component is new during this run of the lifecycle.

Since
2.0
onComponentCreatedback to summary
public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)

This method is guaranteed to be called after the component has been created but before it has been populated with children.

Parameters
ctx:FaceletContext

the FaceletContext for this view execution

c:UIComponent

the UIComponent that has just been created.

parent:UIComponent

the parent UIComponent of the component represented by this element instance.

Since
2.0
onComponentPopulatedback to summary
public void onComponentPopulated(FaceletContext ctx, UIComponent c, UIComponent parent)

This method is guaranteed to be called after the component has been populated with children.

Parameters
ctx:FaceletContext

the FaceletContext for this view execution

c:UIComponent

the UIComponent that has just been populated with children.

parent:UIComponent

the parent UIComponent of the component represented by this element instance.

Since
2.0