Class AjaxHandler
java.lang.Object
jakarta.faces.view.facelets.TagHandler
com.sun.faces.facelets.tag.TagHandlerImpl
com.sun.faces.facelets.tag.jsf.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.
The
If this tag is nested within a single events
attribute for this tag that can be a
ValueExpression
must be evaluated at tag execution time since the event name is used in the process of
Behavior
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 a UIOutput
component instance and set the renderer type to
jakarta.faces.resource.Script
. Set the the following attributes in the component's attribute
Map
: library
with the value "jakarta.faces" and
name
with the value "jsf.js". Install the component resource
using UIViewRoot.addComponentResource()
and specifying head
as the target
argument.
If this tag has component children, add the AjaxBehavior
to AjaxBehaviors
by calling
AjaxBehaviors.pushBehavior(jakarta.faces.context.FacesContext, jakarta.faces.component.behavior.AjaxBehavior, java.lang.String)
. As subsequent child components that implement the ClientBehaviorHolder
interface are evaluated this AjaxBehavior
instance must be added as a behavior to the component.
- Version:
- $Id: AjaxHandler.java 5369 2008-09-08 19:53:45Z rogerk $
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AjaxHandler(TagConfig config)
-
Method Summary
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 Details
-
AjaxHandler
- Parameters:
config
-
-
-
Method Details
-
apply
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
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
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
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
-