- All Implemented Interfaces:
Behavior,ClientBehavior,PartialStateHolder,StateHolder
- Direct Known Subclasses:
RetargetedAjaxBehavior
An instance of this class is added as a
ClientBehavior to a component using the
ClientBehaviorHolder.addClientBehavior(java.lang.String, jakarta.faces.component.behavior.ClientBehavior) 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 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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAjaxBehaviorListener(AjaxBehaviorListener listener) Add the specifiedAjaxBehaviorListenerto the set of listeners registered to receive event notifications from thisAjaxBehavior.getDelay()Returns the delay value, ornullif no value was set.Return a non-emptyCollection<String>of component identifiers that will be used to identify components that should be processed during theexecutephase of the request processing lifecycle.getHints()Return theStringof JavaScript function name that will be used to identify the client callback function that should be run in the event of an error.Return theStringof 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.Return a non-emptyCollection<String>of component identifiers that will be used to identify components that should be processed during therenderphase of the request processing lifecycle.Returns the renderer type of theClientBehaviorRendererto use for the behavior.jakarta.el.ValueExpressiongetValueExpression(String name) Returns theValueExpressionused to calculate the value for the specified property name, if any.booleanReturn the disabled status of this behavior.booleanReturn the immediate status of this behavior.booleanTests whether the immediate attribute is specified.booleanReturn the resetValues status of this behavior.booleanTests whether the resetValues attribute is specified.voidRemove the specifiedAjaxBehaviorListenerfrom the set of listeners registered to receive event notifications from thisAjaxBehavior.voidrestoreState(FacesContext context, Object state) saveState(FacesContext context) Implementation ofStateHolder.saveState(jakarta.faces.context.FacesContext).voidIf less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded.voidsetDisabled(boolean disabled) Sets the disabled status of this behavior.voidsetExecute(Collection<String> execute) Sets the component identifiers that will be used to identify components that should be processed during theexecutephase of the request processing lifecycle.voidsetImmediate(boolean immediate) Sets the immediate status of this behavior.voidsetOnerror(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.voidsetOnevent(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.voidsetRender(Collection<String> render) Sets the component identifiers that will be used to identify components that should be processed during therenderphase of the request processing lifecycle.voidsetResetValues(boolean resetValues) Set the resetValues status of this behavior.voidsetValueExpression(String name, jakarta.el.ValueExpression binding) Sets theValueExpressionused to calculate the value for the specified property name.Methods inherited from class jakarta.faces.component.behavior.ClientBehaviorBase
decode, getRenderer, getScriptMethods inherited from class jakarta.faces.component.behavior.BehaviorBase
addBehaviorListener, broadcast, clearInitialState, initialStateMarked, isTransient, markInitialState, removeBehaviorListener, setTransient
-
Field Details
-
BEHAVIOR_ID
The standard id for this behavior.
- See Also:
-
-
Constructor Details
-
AjaxBehavior
public AjaxBehavior()Default constructor that just creates this instance.
-
-
Method Details
-
getRendererType
Description copied from class:ClientBehaviorBaseReturns the renderer type of the
ClientBehaviorRendererto use for the behavior. The default implementation returns null. Subclasses should either override this method to return a string that identifies the type ofClientBehaviorRendererto use, or should overrideClientBehaviorBase.getScript(jakarta.faces.component.behavior.ClientBehaviorContext)and perform script rendering locally in theClientBehaviorimplementation.- Overrides:
getRendererTypein classClientBehaviorBase- Returns:
- the default renderer type, which is null.
-
getHints
This method returns an unmodifiable
Setcontaining theClientBehaviorHintSUBMITTING.- Specified by:
getHintsin interfaceClientBehavior- Overrides:
getHintsin classClientBehaviorBase- Returns:
- unmodifiable set containing the hint
ClientBehaviorHintSUBMITTING. - Since:
- 2.0
-
getOnerror
Return the
Stringof JavaScript function name that will be used to identify the client callback function that should be run in the event of an error.- Returns:
- the JavaScript function name of
ONERROR. - Since:
- 2.0
-
setOnerror
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- the error handling function name- Since:
- 2.0
-
getOnevent
Return the
Stringof 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:
- the JavaScript function name of
ONEVENT. - Since:
- 2.0
-
setOnevent
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- the event handling function name- Since:
- 2.0
-
getExecute
Return a non-empty
Collection<String>of component identifiers that will be used to identify components that should be processed during theexecutephase of the request processing lifecycle.Note that the returned collection may be unmodifiable. Modifications should be performed by calling
setExecute(java.util.Collection<java.lang.String>).- Returns:
- the JavaScript function name of
EXECUTE. - Since:
- 2.0
-
setExecute
Sets the component identifiers that will be used to identify components that should be processed during the
executephase of the request processing lifecycle.- Parameters:
execute- the ids of components to execute- Since:
- 2.0
-
getDelay
Returns the delay value, or
nullif no value was set.- Returns:
- the delay value.
- Since:
- 2.2
-
setDelay
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- the ajax delay value- Since:
- 2.2
-
getRender
Return a non-empty
Collection<String>of component identifiers that will be used to identify components that should be processed during therenderphase of the request processing lifecycle.Note that the returned collection may be unmodifiable. Modifications should be performed by calling
setRender(java.util.Collection<java.lang.String>).- Returns:
- the ids of components to render.
- Since:
- 2.0
-
setRender
Sets the component identifiers that will be used to identify components that should be processed during the
renderphase of the request processing lifecycle.- Parameters:
render- the ids of components to render- Since:
- 2.0
-
isResetValues
public boolean isResetValues()Return the resetValues status of this behavior.
- Returns:
- the resetValues status.
- Since:
- 2.2
-
setResetValues
public void setResetValues(boolean resetValues) Set the resetValues status of this behavior.
- Parameters:
resetValues- the resetValues status.- Since:
- 2.2
-
isDisabled
public boolean isDisabled()Return the disabled status of this behavior.
- Returns:
- the disabled status of this behavior.
- Since:
- 2.0
-
setDisabled
public void setDisabled(boolean disabled) Sets the disabled status of this behavior.
- Parameters:
disabled- the flag to be set.- Since:
- 2.0
-
isImmediate
public boolean isImmediate()Return the immediate status of this behavior.
- Returns:
- the immediate status.
- Since:
- 2.0
-
setImmediate
public void setImmediate(boolean immediate) Sets the immediate status of this behavior.
- Parameters:
immediate- the flag to be set.- Since:
- 2.0
-
isImmediateSet
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:
- the flag whether the immediate attribute is specified.
- Since:
- 2.0
-
isResetValuesSet
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:
- the flag whether the resetValues attribute is specified.
- Since:
- 2.2
-
getValueExpression
Returns the
ValueExpressionused to calculate the value for the specified property name, if any.- Parameters:
name- Name of the property for which to retrieve aValueExpression- Returns:
- the
ValueExpression. - Throws:
NullPointerException- ifnameisnull
-
setValueExpression
Sets the
ValueExpressionused to calculate the value for the specified property name.- Parameters:
name- Name of the property for which to set aValueExpressionbinding- TheValueExpressionto set, ornullto remove any currently setValueExpression- Throws:
NullPointerException- ifnameisnull
-
addAjaxBehaviorListener
Add the specified
AjaxBehaviorListenerto the set of listeners registered to receive event notifications from thisAjaxBehavior.- Parameters:
listener- TheAjaxBehaviorListenerto be registered- Throws:
NullPointerException- iflistenerisnull- Since:
- 2.0
-
removeAjaxBehaviorListener
Remove the specified
AjaxBehaviorListenerfrom the set of listeners registered to receive event notifications from thisAjaxBehavior.- Parameters:
listener- TheAjaxBehaviorListenerto be removed- Throws:
NullPointerException- iflistenerisnull- Since:
- 2.0
-
saveState
Description copied from class:BehaviorBaseImplementation of
StateHolder.saveState(jakarta.faces.context.FacesContext).- Specified by:
saveStatein interfaceStateHolder- Overrides:
saveStatein classBehaviorBase- Parameters:
context- the Faces context.- Returns:
- the saved state.
-
restoreState
Description copied from class:BehaviorBase- Specified by:
restoreStatein interfaceStateHolder- Overrides:
restoreStatein classBehaviorBase- Parameters:
context- the Faces context.state- the state.
-