Class EventHandler

java.lang.Object
org.apache.myfaces.tobago.facelets.TobagoComponentHandler
org.apache.myfaces.tobago.facelets.EventHandler

public class EventHandler extends TobagoComponentHandler
This tag creates an instance of AjaxBehavior, and associates it with the nearest parent UIComponent that implements ClientBehaviorHolder interface. This tag can be used on single or composite components.

Unless otherwise specified, all attributes accept static values or EL expressions.

According to the documentation, the tag handler implementing this tag should meet the following conditions:

  • Since this tag attach objects to UIComponent instances, and those instances implements Behavior interface, this component should implement BehaviorHolderAttachedObjectHandler interface.
  • f:ajax does not support binding property. In theory we should do something similar to f:convertDateTime tag does: extends from ConverterHandler and override setAttributes method, but in this case BehaviorTagHandlerDelegate has binding property defined, so if we extend from BehaviorHandler we add binding support to f:ajax.
  • This tag works as a attached object handler, but note on the api there is no component to define a target for a behavior. See comment inside apply() method.
Since:
3.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Wraps a method expression in a AjaxBehaviorListener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Class<?>[]
     
    protected jakarta.faces.view.facelets.TagHandlerDelegateFactory
     
    protected final jakarta.faces.view.facelets.FaceletHandler
     
    protected final jakarta.faces.view.facelets.Tag
     
    protected final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EventHandler(jakarta.faces.view.facelets.ComponentConfig config)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(jakarta.faces.view.facelets.FaceletContext ctx, jakarta.faces.component.UIComponent parent)
     
    void
    applyAttachedObject(jakarta.faces.context.FacesContext context, jakarta.faces.component.UIComponent parent)
    This method should create an AjaxBehavior object and attach it to the parent component.
    void
    applyNextHandler(jakarta.faces.view.facelets.FaceletContext arg0, jakarta.faces.component.UIComponent arg1)
     
    protected EventBehavior
    createBehavior(jakarta.faces.context.FacesContext context)
     
    jakarta.faces.component.UIComponent
    createComponent(jakarta.faces.view.facelets.FaceletContext arg0)
     
    protected final jakarta.faces.view.facelets.TagAttribute
     
    jakarta.faces.view.facelets.TagAttribute
     
    jakarta.faces.view.facelets.ComponentConfig
     
    ViewDeclarationLanguage.retargetAttachedObjects uses it to check if the the target to be processed is applicable for this handler
    The documentation says this attribute should not be used since it is not taken into account.
    protected final jakarta.faces.view.facelets.TagAttribute
     
    jakarta.faces.view.facelets.Tag
     
    jakarta.faces.view.facelets.TagAttribute
     
    protected jakarta.faces.view.facelets.TagHandlerDelegate
     
     
    boolean
    isDisabled(jakarta.faces.view.facelets.FaceletContext arg0)
     
    static boolean
    isNew(jakarta.faces.component.UIComponent arg0)
     
    void
    onComponentCreated(jakarta.faces.view.facelets.FaceletContext faceletContext, jakarta.faces.component.UIComponent component, jakarta.faces.component.UIComponent parent)
     
    void
    setAttributes(jakarta.faces.view.facelets.FaceletContext arg0, Object arg1)
     
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • AJAX_BEHAVIOR_LISTENER_SIG

      public static final Class<?>[] AJAX_BEHAVIOR_LISTENER_SIG
    • delegateFactory

      protected jakarta.faces.view.facelets.TagHandlerDelegateFactory delegateFactory
    • tagId

      protected final String tagId
    • tag

      protected final jakarta.faces.view.facelets.Tag tag
    • nextHandler

      protected final jakarta.faces.view.facelets.FaceletHandler nextHandler
  • Constructor Details

    • EventHandler

      public EventHandler(jakarta.faces.view.facelets.ComponentConfig config)
  • Method Details

    • apply

      public void apply(jakarta.faces.view.facelets.FaceletContext ctx, jakarta.faces.component.UIComponent parent) throws IOException
      Throws:
      IOException
    • getEventName

      public String getEventName()
      ViewDeclarationLanguage.retargetAttachedObjects uses it to check if the the target to be processed is applicable for this handler
    • applyAttachedObject

      public void applyAttachedObject(jakarta.faces.context.FacesContext context, jakarta.faces.component.UIComponent parent)
      This method should create an AjaxBehavior object and attach it to the parent component.

      Also, it should check if the parent can apply the selected AjaxBehavior to the selected component through ClientBehaviorHolder.getEventNames() or ClientBehaviorHolder.getDefaultEventName()

    • createBehavior

      protected EventBehavior createBehavior(jakarta.faces.context.FacesContext context)
    • onComponentCreated

      public void onComponentCreated(jakarta.faces.view.facelets.FaceletContext faceletContext, jakarta.faces.component.UIComponent component, jakarta.faces.component.UIComponent parent)
    • getFor

      public String getFor()
      The documentation says this attribute should not be used since it is not taken into account. Instead, getEventName is used on ViewDeclarationLanguage.retargetAttachedObjects.
    • getComponentConfig

      public jakarta.faces.view.facelets.ComponentConfig getComponentConfig()
    • isNew

      public static boolean isNew(jakarta.faces.component.UIComponent arg0)
    • getTagHandlerDelegate

      protected jakarta.faces.view.facelets.TagHandlerDelegate getTagHandlerDelegate()
    • createComponent

      public jakarta.faces.component.UIComponent createComponent(jakarta.faces.view.facelets.FaceletContext arg0)
    • applyNextHandler

      public void applyNextHandler(jakarta.faces.view.facelets.FaceletContext arg0, jakarta.faces.component.UIComponent arg1) throws IOException, jakarta.faces.FacesException, jakarta.el.ELException
      Throws:
      IOException
      jakarta.faces.FacesException
      jakarta.el.ELException
    • getBinding

      public jakarta.faces.view.facelets.TagAttribute getBinding()
    • getTag

      public jakarta.faces.view.facelets.Tag getTag()
    • getTagAttribute

      public jakarta.faces.view.facelets.TagAttribute getTagAttribute(String arg0)
    • getTagId

      public String getTagId()
    • isDisabled

      public boolean isDisabled(jakarta.faces.view.facelets.FaceletContext arg0)
    • setAttributes

      public void setAttributes(jakarta.faces.view.facelets.FaceletContext arg0, Object arg1)
    • getAttribute

      protected final jakarta.faces.view.facelets.TagAttribute getAttribute(String arg0)
    • getRequiredAttribute

      protected final jakarta.faces.view.facelets.TagAttribute getRequiredAttribute(String arg0) throws jakarta.faces.view.facelets.TagException
      Throws:
      jakarta.faces.view.facelets.TagException
    • toString

      public String toString()
      Overrides:
      toString in class Object