public class AjaxBehavior extends ClientBehaviorBase
An instance of this class
is added as a ClientBehavior to a component using the ClientBehaviorHolder.addClientBehavior(java.lang.String, javax.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.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
ALL |
private static java.util.List<java.lang.String> |
ALL_LIST |
static java.lang.String |
BEHAVIOR_ID
The standard id for this behavior. |
private java.util.Map<java.lang.String,javax.el.ValueExpression> |
bindings |
private java.lang.Boolean |
disabled |
private static java.lang.String |
DISABLED |
private java.util.List<java.lang.String> |
execute |
private static java.lang.String |
EXECUTE |
private static java.lang.String |
FORM |
private static java.util.List<java.lang.String> |
FORM_LIST |
private static java.util.Set<ClientBehaviorHint> |
HINTS |
private java.lang.Boolean |
immediate |
private static java.lang.String |
IMMEDIATE |
private static java.lang.String |
NONE |
private static java.util.List<java.lang.String> |
NONE_LIST |
private java.lang.String |
onerror |
private static java.lang.String |
ONERROR |
private java.lang.String |
onevent |
private static java.lang.String |
ONEVENT |
private java.util.List<java.lang.String> |
render |
private static java.lang.String |
RENDER |
private static java.util.regex.Pattern |
SPLIT_PATTERN |
private static java.lang.String |
THIS |
private static java.util.List<java.lang.String> |
THIS_LIST |
| Constructor and Description |
|---|
AjaxBehavior() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAjaxBehaviorListener(AjaxBehaviorListener listener)
Add the specified |
private java.util.List<java.lang.String> |
copyToList(java.util.Collection<java.lang.String> collection) |
private java.lang.Object |
eval(java.lang.String propertyName,
java.lang.Object value) |
private java.util.Collection<java.lang.String> |
getCollectionValue(java.lang.String propertyName,
java.util.Collection<java.lang.String> collection) |
java.util.Collection<java.lang.String> |
getExecute()
Return a non-empty
|
java.util.Set<ClientBehaviorHint> |
getHints()
This method returns an unmodifiable |
java.lang.String |
getOnerror()
Return the |
java.lang.String |
getOnevent()
Return the |
java.util.Collection<java.lang.String> |
getRender()
Return a non-empty
|
java.lang.String |
getRendererType()
Returns the renderer type of the
|
javax.el.ValueExpression |
getValueExpression(java.lang.String name)
Returns the |
boolean |
isDisabled()
Return the disabled status of this behavior. |
boolean |
isImmediate()
Return the immediate status of this behaivor. |
boolean |
isImmediateSet()
Tests whether the immediate attribute is specified. |
void |
removeAjaxBehaviorListener(AjaxBehaviorListener listener)
Remove the specified |
private static java.util.Map<java.lang.String,javax.el.ValueExpression> |
restoreBindings(FacesContext context,
java.lang.Object state) |
private static java.util.List<java.lang.String> |
restoreList(java.lang.String propertyName,
java.lang.Object state) |
void |
restoreState(FacesContext context,
java.lang.Object state)
Implementation of
|
private static java.lang.Object |
saveBindings(FacesContext context,
java.util.Map<java.lang.String,javax.el.ValueExpression> bindings) |
private static java.lang.Object |
saveList(java.util.List<java.lang.String> list) |
java.lang.Object |
saveState(FacesContext context)
Implementation of
|
void |
setDisabled(boolean disabled)
Sets the disabled status of this behavior. |
void |
setExecute(java.util.Collection<java.lang.String> execute)
Sets the component identifiers that
will be used to identify components that should be
processed during the |
void |
setImmediate(boolean immediate)
Sets the immediate status of this behavior. |
private void |
setLiteralValue(java.lang.String propertyName,
javax.el.ValueExpression expression) |
void |
setOnerror(java.lang.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. |
void |
setOnevent(java.lang.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. |
void |
setRender(java.util.Collection<java.lang.String> render)
Sets the component identifiers that
will be used to identify components that should be
processed during the |
void |
setValueExpression(java.lang.String name,
javax.el.ValueExpression binding)
Sets the |
private static java.util.List<java.lang.String> |
toList(java.lang.String propertyName,
javax.el.ValueExpression expression,
java.lang.Object value) |
private static java.util.List<java.lang.String> |
toSingletonList(java.lang.String propertyName,
java.lang.String value) |
decode, getRenderer, getScriptaddBehaviorListener, broadcast, clearInitialState, initialStateMarked, isTransient, markInitialState, removeBehaviorListener, setTransientpublic static final java.lang.String BEHAVIOR_ID
The standard id for this behavior.
private static final java.util.Set<ClientBehaviorHint> HINTS
private java.lang.String onerror
private java.lang.String onevent
private java.util.List<java.lang.String> execute
private java.util.List<java.lang.String> render
private java.lang.Boolean disabled
private java.lang.Boolean immediate
private java.util.Map<java.lang.String,javax.el.ValueExpression> bindings
private static final java.lang.String ONEVENT
private static final java.lang.String ONERROR
private static final java.lang.String IMMEDIATE
private static final java.lang.String DISABLED
private static final java.lang.String EXECUTE
private static final java.lang.String RENDER
private static java.lang.String ALL
private static java.lang.String FORM
private static java.lang.String THIS
private static java.lang.String NONE
private static java.util.List<java.lang.String> ALL_LIST
private static java.util.List<java.lang.String> FORM_LIST
private static java.util.List<java.lang.String> THIS_LIST
private static java.util.List<java.lang.String> NONE_LIST
private static java.util.regex.Pattern SPLIT_PATTERN
public java.lang.String getRendererType()
ClientBehaviorBaseReturns 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
ClientBehaviorBase.getScript(javax.faces.component.behavior.ClientBehaviorContext) and perform script rendering locally in the
ClientBehavior implementation.
getRendererType in class ClientBehaviorBasepublic java.util.Set<ClientBehaviorHint> getHints()
This method returns an unmodifiable Set containing
the ClientBehaviorHint SUBMITTING.
getHints in interface ClientBehaviorgetHints in class ClientBehaviorBaseClientBehaviorHint
SUBMITTING.public java.lang.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.
public void setOnerror(java.lang.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.
onerror - the error handling function namepublic java.lang.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.
public void setOnevent(java.lang.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.
onevent - the event handling function namepublic java.util.Collection<java.lang.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(java.util.Collection<java.lang.String>).
public void setExecute(java.util.Collection<java.lang.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.
execute - the ids of components to executepublic java.util.Collection<java.lang.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(java.util.Collection<java.lang.String>).
public void setRender(java.util.Collection<java.lang.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.
render - the ids of components to renderpublic boolean isDisabled()
Return the disabled status of this behavior.
public void setDisabled(boolean disabled)
Sets the disabled status of this behavior.
public boolean isImmediate()
Return the immediate status of this behaivor.
public void setImmediate(boolean immediate)
Sets the immediate status of this behavior.
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.
public javax.el.ValueExpression getValueExpression(java.lang.String name)
Returns the ValueExpression
used to calculate the value for the specified property name, if any.
name - Name of the property for which to retrieve a
ValueExpressionjava.lang.NullPointerException - if name
is nullpublic void setValueExpression(java.lang.String name,
javax.el.ValueExpression binding)
Sets the ValueExpression
used to calculate the value for the specified property name.
name - Name of the property for which to set a
ValueExpressionbinding - The ValueExpression to set, or null
to remove any currently set ValueExpressionjava.lang.NullPointerException - if name
is nullpublic void addAjaxBehaviorListener(AjaxBehaviorListener listener)
Add the specified AjaxBehaviorListener
to the set of listeners registered to receive event notifications
from this AjaxBehavior.
listener - The AjaxBehaviorListener to be registeredjava.lang.NullPointerException - if listener
is nullpublic void removeAjaxBehaviorListener(AjaxBehaviorListener listener)
Remove the specified AjaxBehaviorListener
from the set of listeners registered to receive event notifications
from this AjaxBehavior.
listener - The AjaxBehaviorListener to be removedjava.lang.NullPointerException - if listener
is nullpublic java.lang.Object saveState(FacesContext context)
BehaviorBaseImplementation of
StateHolder.saveState(javax.faces.context.FacesContext).
saveState in interface StateHoldersaveState in class BehaviorBasepublic void restoreState(FacesContext context, java.lang.Object state)
BehaviorBaseImplementation of
StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object).
restoreState in interface StateHolderrestoreState in class BehaviorBaseprivate static java.lang.Object saveBindings(FacesContext context, java.util.Map<java.lang.String,javax.el.ValueExpression> bindings)
private static java.util.Map<java.lang.String,javax.el.ValueExpression> restoreBindings(FacesContext context, java.lang.Object state)
private static java.lang.Object saveList(java.util.List<java.lang.String> list)
private static java.util.List<java.lang.String> restoreList(java.lang.String propertyName,
java.lang.Object state)
private java.lang.Object eval(java.lang.String propertyName,
java.lang.Object value)
private java.util.Collection<java.lang.String> getCollectionValue(java.lang.String propertyName,
java.util.Collection<java.lang.String> collection)
private void setLiteralValue(java.lang.String propertyName,
javax.el.ValueExpression expression)
private static java.util.List<java.lang.String> toList(java.lang.String propertyName,
javax.el.ValueExpression expression,
java.lang.Object value)
private static java.util.List<java.lang.String> toSingletonList(java.lang.String propertyName,
java.lang.String value)
private java.util.List<java.lang.String> copyToList(java.util.Collection<java.lang.String> collection)