Class ComponentHandler

java.lang.Object
All Implemented Interfaces:
FaceletHandler
Direct Known Subclasses:
ComponentRefHandler, CompositeComponentTagHandler, HtmlComponentHandler, PassThroughElementComponentHandler, RenderFacetHandler, RepeatHandler, ScriptResourceHandler, StylesheetResourceHandler

public class ComponentHandler extends DelegatingMetaTagHandler

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(jakarta.faces.view.facelets.ComponentHandler) 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 ProjectStage.Development, Put the Location for this element into the component attribute Map under the key given by the value of the symbolic constant 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 UniqueIdVendor must be located and its UniqueIdVendor.createUniqueId(jakarta.faces.context.FacesContext, java.lang.String) method must be called to derive the id. If no such instance can be found, call UIViewRoot.createUniqueId() to derive the id.

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

  6. onComponentCreated(jakarta.faces.view.facelets.FaceletContext, jakarta.faces.component.UIComponent, jakarta.faces.component.UIComponent) is called.

  7. UIComponent.pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent) 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(jakarta.faces.context.FacesContext) 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.

Since:
2.0