Top Description Fields Constructors Methods
jakarta.faces.component.behavior

public Class AjaxBehavior

extends ClientBehaviorBase
Class Inheritance
Static Imports
jakarta.faces.component.behavior.ClientBehaviorHint.SUBMITTING, java.util.Collections.unmodifiableSet

An instance of this class is added as a ClientBehavior to a component using the jakarta.faces.component.behavior.ClientBehaviorHolder#addClientBehavior contract that components implement. The presence of this ClientBehavior will cause the rendering of JavaScript that produces an Ajax request using the specification public JavaScript API when the component is rendered.

If the component is an instance of jakarta.faces.component.EditableValueHolder, Where at all possible, the component must have the UI register the ajax event when the initial value is changed, not when focus is lost on the component.

Since
2.0

Field Summary

Modifier and TypeField and Description
private static String
private static List<String>
public static final String
BEHAVIOR_ID

The standard id for this behavior.

private Map<String, ValueExpression>
private String
private static final String
private Boolean
private static final String
private List<String>
private static final String
private static String
private static List<String>
private static final Set<ClientBehaviorHint>
private Boolean
private static final String
private static String
private static List<String>
private String
private static final String
private String
private static final String
private List<String>
private static final String
private static final String
private Boolean
private static Pattern
private static String
private static List<String>

Constructor Summary

AccessConstructor and Description
public
AjaxBehavior()

Default constructor that just creates this instance.

Method Summary

Modifier and TypeMethod and Description
public void
addAjaxBehaviorListener(AjaxBehaviorListener
The AjaxBehaviorListener to be registered
listener
)

Add the specified AjaxBehaviorListener to the set of listeners registered to receive event notifications from this AjaxBehavior.

private List<String>
private Object
eval(String propertyName, Object value)

private Collection<String>
getCollectionValue(String propertyName, Collection<String> collection)

public String

Returns:

the delay value.
getDelay
()

Returns the delay value, or null if no value was set.

public Collection<String>

Returns:

the JavaScript function name of EXECUTE.
getExecute
()

Return a non-empty Collection<String> of component identifiers that will be used to identify components that should be processed during the execute phase of the request processing lifecycle.

public Set<ClientBehaviorHint>

Returns:

unmodifiable set containing the hint ClientBehaviorHint SUBMITTING.
getHints
()

Overrides jakarta.faces.component.behavior.ClientBehaviorBase.getHints.

Implements jakarta.faces.component.behavior.ClientBehavior.getHints.

This method returns an unmodifiable Set containing the ClientBehaviorHint SUBMITTING.

public String

Returns:

the JavaScript function name of ONERROR.
getOnerror
()

Return the String of JavaScript function name that will be used to identify the client callback function that should be run in the event of an error.

public String

Returns:

the JavaScript function name of ONEVENT.
getOnevent
()

Return the String of JavaScript function name that will be used to identify the client callback function that should be run on the occurance of a client-side event.

public Collection<String>

Returns:

the ids of components to render.
getRender
()

Return a non-empty Collection<String> of component identifiers that will be used to identify components that should be processed during the render phase of the request processing lifecycle.

public String
getRendererType()

Overrides jakarta.faces.component.behavior.ClientBehaviorBase.getRendererType.

Returns the renderer type of the ClientBehaviorRenderer to use for the behavior.

public ValueExpression

Returns:

the ValueExpression.
getValueExpression
(String
Name of the property for which to retrieve a ValueExpression
name
)

Returns the ValueExpression used to calculate the value for the specified property name, if any.

public boolean

Returns:

the disabled status of this behavior.
isDisabled
()

Return the disabled status of this behavior.

public boolean

Returns:

the immediate status.
isImmediate
()

Return the immediate status of this behavior.

public boolean

Returns:

the flag whether the immediate attribute is specified.
isImmediateSet
()

Tests whether the immediate attribute is specified.

public boolean

Returns:

the resetValues status.
isResetValues
()

Return the resetValues status of this behavior.

public boolean

Returns:

the flag whether the resetValues attribute is specified.
isResetValuesSet
()

Tests whether the resetValues attribute is specified.

public void
removeAjaxBehaviorListener(AjaxBehaviorListener
The AjaxBehaviorListener to be removed
listener
)

Remove the specified AjaxBehaviorListener from the set of listeners registered to receive event notifications from this AjaxBehavior.

private static Map<String, ValueExpression>
private static List<String>
restoreList(String propertyName, Object state)

public void
private static Object
private static Object
public Object
public void
setDelay(String
the ajax delay value
delay
)

If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded.

public void
setDisabled(boolean
the flag to be set.
disabled
)

Sets the disabled status of this behavior.

public void
setExecute(Collection<String>
the ids of components to execute
execute
)

Sets the component identifiers that will be used to identify components that should be processed during the execute phase of the request processing lifecycle.

public void
setImmediate(boolean
the flag to be set.
immediate
)

Sets the immediate status of this behavior.

private void
setLiteralValue(String propertyName, ValueExpression expression)

public void
setOnerror(String
the error handling function name
onerror
)

Sets the JavaScript function name that will be used to identify the client callback function that should be run in the event of an error.

public void
setOnevent(String
the event handling function name
onevent
)

Sets the JavaScript function name that will be used to identify the client callback function that should be run in response to event activity.

public void
setRender(Collection<String>
the ids of components to render
render
)

Sets the component identifiers that will be used to identify components that should be processed during the render phase of the request processing lifecycle.

public void
setResetValues(boolean
the resetValues status.
resetValues
)

Set the resetValues status of this behavior.

public void
setValueExpression(String
Name of the property for which to set a ValueExpression
name
,
ValueExpression
The ValueExpression to set, or null to remove any currently set ValueExpression
binding
)

Sets the ValueExpression used to calculate the value for the specified property name.

private static List<String>
toList(String propertyName, ValueExpression expression, Object value)

private static List<String>
toSingletonList(String propertyName, String value)

Inherited from jakarta.faces.component.behavior.ClientBehaviorBase:
decodegetRenderergetScript

Field Detail

ALLback to summary
private static String ALL
ALL_LISTback to summary
private static List<String> ALL_LIST
BEHAVIOR_IDback to summary
public static final String BEHAVIOR_ID

The standard id for this behavior.

bindingsback to summary
private Map<String, ValueExpression> bindings
delayback to summary
private String delay
DELAYback to summary
private static final String DELAY
disabledback to summary
private Boolean disabled
DISABLEDback to summary
private static final String DISABLED
executeback to summary
private List<String> execute
EXECUTEback to summary
private static final String EXECUTE
FORMback to summary
private static String FORM
FORM_LISTback to summary
private static List<String> FORM_LIST
HINTSback to summary
private static final Set<ClientBehaviorHint> HINTS
immediateback to summary
private Boolean immediate
IMMEDIATEback to summary
private static final String IMMEDIATE
NONEback to summary
private static String NONE
NONE_LISTback to summary
private static List<String> NONE_LIST
onerrorback to summary
private String onerror
ONERRORback to summary
private static final String ONERROR
oneventback to summary
private String onevent
ONEVENTback to summary
private static final String ONEVENT
renderback to summary
private List<String> render
RENDERback to summary
private static final String RENDER
RESET_VALUESback to summary
private static final String RESET_VALUES
resetValuesback to summary
private Boolean resetValues
SPLIT_PATTERNback to summary
private static Pattern SPLIT_PATTERN
THISback to summary
private static String THIS
THIS_LISTback to summary
private static List<String> THIS_LIST

Constructor Detail

AjaxBehaviorback to summary
public AjaxBehavior()

Default constructor that just creates this instance.

Method Detail

addAjaxBehaviorListenerback to summary
public void addAjaxBehaviorListener(AjaxBehaviorListener listener)

Add the specified AjaxBehaviorListener to the set of listeners registered to receive event notifications from this AjaxBehavior.

Parameters
listener:AjaxBehaviorListener

The AjaxBehaviorListener to be registered

Exceptions
NullPointerException:
if listener is null
Since
2.0
copyToListback to summary
private List<String> copyToList(Collection<String> collection)
evalback to summary
private Object eval(String propertyName, Object value)
getCollectionValueback to summary
private Collection<String> getCollectionValue(String propertyName, Collection<String> collection)
Annotations
@SuppressWarnings:unchecked
getDelayback to summary
public String getDelay()

Returns the delay value, or null if no value was set.

Returns:String

the delay value.

Since
2.2
getExecuteback to summary
public Collection<String> getExecute()

Return a non-empty Collection<String> of component identifiers that will be used to identify components that should be processed during the execute phase of the request processing lifecycle.

Note that the returned collection may be unmodifiable. Modifications should be performed by calling setExecute.

Returns:Collection<String>

the JavaScript function name of EXECUTE.

Since
2.0
getHintsback to summary
public Set<ClientBehaviorHint> getHints()

Overrides jakarta.faces.component.behavior.ClientBehaviorBase.getHints.

Implements jakarta.faces.component.behavior.ClientBehavior.getHints.

This method returns an unmodifiable Set containing the ClientBehaviorHint SUBMITTING.

Returns:Set<ClientBehaviorHint>

unmodifiable set containing the hint ClientBehaviorHint SUBMITTING.

Annotations
@Override
Since
2.0
getOnerrorback to summary
public String getOnerror()

Return the String of JavaScript function name that will be used to identify the client callback function that should be run in the event of an error.

Returns:String

the JavaScript function name of ONERROR.

Since
2.0
getOneventback to summary
public String getOnevent()

Return the String of JavaScript function name that will be used to identify the client callback function that should be run on the occurance of a client-side event.

Returns:String

the JavaScript function name of ONEVENT.

Since
2.0
getRenderback to summary
public Collection<String> getRender()

Return a non-empty Collection<String> of component identifiers that will be used to identify components that should be processed during the render phase of the request processing lifecycle.

Note that the returned collection may be unmodifiable. Modifications should be performed by calling setRender.

Returns:Collection<String>

the ids of components to render.

Since
2.0
getRendererTypeback to summary
public String getRendererType()

Overrides jakarta.faces.component.behavior.ClientBehaviorBase.getRendererType.

Doc from jakarta.faces.component.behavior.ClientBehaviorBase.getRendererType.

Returns the renderer type of the ClientBehaviorRenderer to use for the behavior. The default implementation returns null. Subclasses should either override this method to return a string that identifies the type of ClientBehaviorRenderer to use, or should override getScript and perform script rendering locally in the ClientBehavior implementation.

Returns:String

the default renderer type, which is null.

Annotations
@Override
getValueExpressionback to summary
public ValueExpression getValueExpression(String name)

Returns the ValueExpression used to calculate the value for the specified property name, if any.

Parameters
name:String

Name of the property for which to retrieve a ValueExpression

Returns:ValueExpression

the ValueExpression.

Exceptions
NullPointerException:
if name is null
isDisabledback to summary
public boolean isDisabled()

Return the disabled status of this behavior.

Returns:boolean

the disabled status of this behavior.

Since
2.0
isImmediateback to summary
public boolean isImmediate()

Return the immediate status of this behavior.

Returns:boolean

the immediate status.

Since
2.0
isImmediateSetback to summary
public boolean isImmediateSet()

Tests whether the immediate attribute is specified. Returns true if the immediate attribute is specified, either as a locally set property or as a value expression. This information allows an associated client behavior renderer to fall back on the parent component's immediate status when immediate is not explicitly specified on the AjaxBehavior.

Returns:boolean

the flag whether the immediate attribute is specified.

Since
2.0
isResetValuesback to summary
public boolean isResetValues()

Return the resetValues status of this behavior.

Returns:boolean

the resetValues status.

Since
2.2
isResetValuesSetback to summary
public boolean isResetValuesSet()

Tests whether the resetValues attribute is specified. Returns true if the resetValues attribute is specified, either as a locally set property or as a value expression.

Returns:boolean

the flag whether the resetValues attribute is specified.

Since
2.2
removeAjaxBehaviorListenerback to summary
public void removeAjaxBehaviorListener(AjaxBehaviorListener listener)

Remove the specified AjaxBehaviorListener from the set of listeners registered to receive event notifications from this AjaxBehavior.

Parameters
listener:AjaxBehaviorListener

The AjaxBehaviorListener to be removed

Exceptions
NullPointerException:
if listener is null
Since
2.0
restoreBindingsback to summary
private static Map<String, ValueExpression> restoreBindings(FacesContext context, Object state)
restoreListback to summary
private static List<String> restoreList(String propertyName, Object state)
restoreStateback to summary
public void restoreState(FacesContext context, Object state)

Overrides jakarta.faces.component.behavior.BehaviorBase.restoreState.

Implements jakarta.faces.component.StateHolder.restoreState.

Doc from jakarta.faces.component.behavior.BehaviorBase.restoreState.

Implementation of jakarta.faces.component.StateHolder#restoreState.

Parameters
context:FacesContext

Doc from jakarta.faces.component.StateHolder.restoreState.

the Faces context.

state:Object

Doc from jakarta.faces.component.StateHolder.restoreState.

the state.

Annotations
@Override
saveBindingsback to summary
private static Object saveBindings(FacesContext context, Map<String, ValueExpression> bindings)
saveListback to summary
private static Object saveList(List<String> list)
saveStateback to summary
public Object saveState(FacesContext context)

Overrides jakarta.faces.component.behavior.BehaviorBase.saveState.

Implements jakarta.faces.component.StateHolder.saveState.

Doc from jakarta.faces.component.behavior.BehaviorBase.saveState.

Implementation of jakarta.faces.component.StateHolder#saveState.

Parameters
context:FacesContext

Doc from jakarta.faces.component.StateHolder.saveState.

the Faces context.

Returns:Object

Doc from jakarta.faces.component.StateHolder.saveState.

the saved state.

Annotations
@Override
setDelayback to summary
public void setDelay(String delay)

If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded. The default value of this option is 300. If the value of delay is the literal string 'none' without the quotes, no delay is used.

Parameters
delay:String

the ajax delay value

Since
2.2
setDisabledback to summary
public void setDisabled(boolean disabled)

Sets the disabled status of this behavior.

Parameters
disabled:boolean

the flag to be set.

Since
2.0
setExecuteback to summary
public void setExecute(Collection<String> execute)

Sets the component identifiers that will be used to identify components that should be processed during the execute phase of the request processing lifecycle.

Parameters
execute:Collection<String>

the ids of components to execute

Since
2.0
setImmediateback to summary
public void setImmediate(boolean immediate)

Sets the immediate status of this behavior.

Parameters
immediate:boolean

the flag to be set.

Since
2.0
setLiteralValueback to summary
private void setLiteralValue(String propertyName, ValueExpression expression)
setOnerrorback to summary
public void setOnerror(String onerror)

Sets the JavaScript function name that will be used to identify the client callback function that should be run in the event of an error.

Parameters
onerror:String

the error handling function name

Since
2.0
setOneventback to summary
public void setOnevent(String onevent)

Sets the JavaScript function name that will be used to identify the client callback function that should be run in response to event activity.

Parameters
onevent:String

the event handling function name

Since
2.0
setRenderback to summary
public void setRender(Collection<String> render)

Sets the component identifiers that will be used to identify components that should be processed during the render phase of the request processing lifecycle.

Parameters
render:Collection<String>

the ids of components to render

Since
2.0
setResetValuesback to summary
public void setResetValues(boolean resetValues)

Set the resetValues status of this behavior.

Parameters
resetValues:boolean

the resetValues status.

Since
2.2
setValueExpressionback to summary
public void setValueExpression(String name, ValueExpression binding)

Sets the ValueExpression used to calculate the value for the specified property name.

Parameters
name:String

Name of the property for which to set a ValueExpression

binding:ValueExpression

The ValueExpression to set, or null to remove any currently set ValueExpression

Exceptions
NullPointerException:
if name is null
toListback to summary
private static List<String> toList(String propertyName, ValueExpression expression, Object value)
toSingletonListback to summary
private static List<String> toSingletonList(String propertyName, String value)