Class AjaxHandler
- java.lang.Object
-
- jakarta.faces.view.facelets.TagHandler
-
- com.sun.faces.facelets.tag.TagHandlerImpl
-
- com.sun.faces.facelets.tag.faces.core.AjaxHandler
-
- All Implemented Interfaces:
AttachedObjectHandler
,BehaviorHolderAttachedObjectHandler
,FaceletHandler
public final class AjaxHandler extends TagHandlerImpl implements BehaviorHolderAttachedObjectHandler
Enable one or more components in the view to perform Ajax operations. This tag handler must create an instance of
AjaxBehavior
using the tag attribute values.TheIf this tag is nested within a singleevents
attribute for this tag that can be aValueExpression
must be evaluated at tag execution time since the event name is used in the process ofBehavior
creation.ClientBehaviorHolder
component:- If the
events
attribute value is not specified, obtain the default event name by callingClientBehaviorHolder.getDefaultEventName()
. If that returnsnull
throw anexception
. - If the
events
attribute value is specified, ensure it that it exists in theCollection
returned from a call toClientBehaviorHolder.getEventNames()
and throw anexception
if it doesn't exist. - Add the
AjaxBehavior
instance to theClientBehaviorHolder
component by callingClientBehaviorHolder.addClientBehavior(java.lang.String, jakarta.faces.component.behavior.ClientBehavior)
passingevent
and theAjaxBehavior
instance.
Check for the existence of the Ajax resource by calling
UIViewRoot.getComponentResources()
. If the Ajax resource does not exist, create aUIOutput
component instance and set the renderer type tojakarta.faces.resource.Script
. Set the the following attributes in the component's attributeMap
:library
with the value "jakarta.faces" andname
with the value "faces.js". Install the component resource usingUIViewRoot.addComponentResource()
and specifyinghead
as thetarget
argument.If this tag has component children, add the
AjaxBehavior
toAjaxBehaviors
by callingAjaxBehaviors.pushBehavior(jakarta.faces.context.FacesContext, jakarta.faces.component.behavior.AjaxBehavior, java.lang.String)
. As subsequent child components that implement theClientBehaviorHolder
interface are evaluated thisAjaxBehavior
instance must be added as a behavior to the component.- Version:
- $Id: AjaxHandler.java 5369 2008-09-08 19:53:45Z rogerk $
-
-
Field Summary
-
Fields inherited from class jakarta.faces.view.facelets.TagHandler
nextHandler, tag, tagId
-
-
Constructor Summary
Constructors Constructor Description AjaxHandler(TagConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(FaceletContext ctx, UIComponent parent)
Process changes on a particular UIComponentvoid
applyAttachedObject(FacesContext context, UIComponent parent)
Take the argumentparent
and apply this attached object to it.String
getEventName()
Return the client event name to which this behavior applies.String
getFor()
Return the value of the "for" attribute specified by the page author on the tag for thisAttachedObjectHandler
.-
Methods inherited from class com.sun.faces.facelets.tag.TagHandlerImpl
findNextByType, findNextByType
-
Methods inherited from class jakarta.faces.view.facelets.TagHandler
getAttribute, getRequiredAttribute, toString
-
-
-
-
Constructor Detail
-
AjaxHandler
public AjaxHandler(TagConfig config)
- Parameters:
config
-
-
-
Method Detail
-
apply
public void apply(FaceletContext ctx, UIComponent parent) throws IOException
Description copied from interface:FaceletHandler
Process changes on a particular UIComponent
- Specified by:
apply
in interfaceFaceletHandler
- Parameters:
ctx
- the current FaceletContext instance for this executionparent
- the parent UIComponent to operate upon- Throws:
IOException
- if unable to loadrelativePath
-
applyAttachedObject
public void applyAttachedObject(FacesContext context, UIComponent parent)
Description copied from interface:AttachedObjectHandler
Take the argument
parent
and apply this attached object to it. The action taken varies with class that implements one of the subinterfaces of this interface.- Specified by:
applyAttachedObject
in interfaceAttachedObjectHandler
- Parameters:
context
- TheFacesContext
for this requestparent
- TheUIComponent
to which this particular attached object must be applied.
-
getFor
public String getFor()
Description copied from interface:AttachedObjectHandler
Return the value of the "for" attribute specified by the page author on the tag for this
AttachedObjectHandler
.- Specified by:
getFor
in interfaceAttachedObjectHandler
- Returns:
- the value of the "for" attribute for this attached object
-
getEventName
public String getEventName()
Description copied from interface:BehaviorHolderAttachedObjectHandler
Return the client event name to which this behavior applies.
- Specified by:
getEventName
in interfaceBehaviorHolderAttachedObjectHandler
- Returns:
- the client event name for this behavior
-
-