Class AjaxHandler
- java.lang.Object
-
- jakarta.faces.view.facelets.TagHandler
-
- org.apache.myfaces.view.facelets.tag.faces.core.AjaxHandler
-
- All Implemented Interfaces:
AttachedObjectHandler
,BehaviorHolderAttachedObjectHandler
,FaceletHandler
@JSFFaceletTag(name="f:ajax") public class AjaxHandler extends TagHandler implements BehaviorHolderAttachedObjectHandler
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.
- Version:
- $Revision$ $Date$
- Author:
- Leonardo Uribe (latest modification by $Author$)
-
-
Field Summary
Fields Modifier and Type Field Description static Class<?>[]
AJAX_BEHAVIOR_LISTENER_SIG
static String
FACES_JS_DYNAMICALLY_ADDED
Constant used to check if in the current build view it has been rendered the standard jsf javascript library.-
Fields inherited from class jakarta.faces.view.facelets.TagHandler
nextHandler, tag, tagId
-
-
Constructor Summary
Constructors Constructor Description AjaxHandler(TagConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(FaceletContext ctx, UIComponent parent)
void
applyAttachedObject(FacesContext context, UIComponent parent)
This method should create an AjaxBehavior object and attach it to the parent component.String
getEventName()
ViewDeclarationLanguage.retargetAttachedObjects uses it to check if the the target to be processed is applicable for this handlerString
getFor()
The documentation says this attribute should not be used since it is not taken into account.static void
registerFacesJsResource(FaceletContext ctx, UIComponent parent)
protected <T> void
setAttribute(FaceletContext faceletContext, AjaxBehavior behavior, TagAttribute attr, Class<T> type)
protected <T> void
setAttribute(FaceletContext faceletContext, AjaxBehavior behavior, TagAttribute attr, Class<T> type, Consumer<T> setter)
-
Methods inherited from class jakarta.faces.view.facelets.TagHandler
getAttribute, getRequiredAttribute, toString
-
-
-
-
Field Detail
-
AJAX_BEHAVIOR_LISTENER_SIG
public static final Class<?>[] AJAX_BEHAVIOR_LISTENER_SIG
-
FACES_JS_DYNAMICALLY_ADDED
public static final String FACES_JS_DYNAMICALLY_ADDED
Constant used to check if in the current build view it has been rendered the standard jsf javascript library. It is necessary to remove this key from facesContext attribute map after build, to keep working this code for next views to be built.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AjaxHandler
public AjaxHandler(TagConfig config)
-
-
Method Detail
-
apply
public void apply(FaceletContext ctx, UIComponent parent) throws IOException
- Specified by:
apply
in interfaceFaceletHandler
- Throws:
IOException
-
registerFacesJsResource
public static void registerFacesJsResource(FaceletContext ctx, UIComponent parent)
-
getEventName
public String getEventName()
ViewDeclarationLanguage.retargetAttachedObjects uses it to check if the the target to be processed is applicable for this handler- Specified by:
getEventName
in interfaceBehaviorHolderAttachedObjectHandler
-
applyAttachedObject
public void applyAttachedObject(FacesContext context, 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()- Specified by:
applyAttachedObject
in interfaceAttachedObjectHandler
-
setAttribute
protected <T> void setAttribute(FaceletContext faceletContext, AjaxBehavior behavior, TagAttribute attr, Class<T> type)
-
setAttribute
protected <T> void setAttribute(FaceletContext faceletContext, AjaxBehavior behavior, TagAttribute attr, Class<T> type, Consumer<T> setter)
-
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.- Specified by:
getFor
in interfaceAttachedObjectHandler
-
-