Class ComponentTagHandlerDelegate


  • public class ComponentTagHandlerDelegate
    extends TagHandlerDelegate
    Implementation of the tag logic used in the Faces specification. See org.apache.myfaces.view.facelets.tag.faces.ComponentHandler
    Since:
    2.0
    Version:
    $Revision$ $Date$
    Author:
    Leonardo Uribe (latest modification by $Author$)
    • Constructor Detail

      • ComponentTagHandlerDelegate

        public ComponentTagHandlerDelegate​(ComponentHandler delegate)
    • Method Detail

      • apply

        public void apply​(FaceletContext ctx,
                          UIComponent parent)
                   throws IOException
        Method handles UIComponent tree creation in accordance with the Faces 1.2 spec.
        1. First determines this UIComponent's id by calling getId(FaceletContext).
        2. Search the parent for an existing UIComponent of the id we just grabbed
        3. If found, mark its children for deletion.
        4. If not found, call createComponent.
          1. Only here do we apply TagHandler#setAttributes(FaceletCompositionContext, Object)
          2. Set the UIComponent's id
          3. Set the RendererType of this instance
        5. Now apply the nextHandler, passing the UIComponent we've created/found.
        6. Now add the UIComponent to the passed parent
        7. Lastly, if the UIComponent already existed (found), then #finalizeForDeletion(FaceletCompositionContext, UIComponent) for deletion.
        See jakarta.faces.view.facelets.FaceletHandler#apply(jakarta.faces.view.facelets.FaceletContext, jakarta.faces.component.UIComponent)
        Specified by:
        apply in class TagHandlerDelegate
        Throws:
        TagException - if the UIComponent parent is null
        IOException
      • getFacetName

        protected final String getFacetName​(FaceletContext ctx,
                                            UIComponent parent)
        Return the Facet name we are scoped in, otherwise null
        Parameters:
        ctx -
        Returns:
      • createComponent

        protected UIComponent createComponent​(FaceletContext ctx)
        If the binding attribute was specified, use that in conjuction with our componentType String variable to call createComponent on the Application, otherwise just pass the componentType String.

        If the binding was used, then set the ValueExpression "binding" on the created UIComponent.

        See Application#createComponent(jakarta.faces.el.ValueBinding, jakarta.faces.context.FacesContext, java.lang.String) See Application#createComponent(java.lang.String)
        Parameters:
        ctx - FaceletContext to use in creating a component
        Returns:
      • getId

        protected String getId​(FaceletContext ctx)
        If the id TagAttribute was specified, get it's value, otherwise generate a unique id from our tagId. See TagAttribute#getValue(FaceletContext)
        Parameters:
        ctx - FaceletContext to use
        Returns:
        what should be a unique Id