public class BehaviorBase extends java.lang.Object implements Behavior, PartialStateHolder
BehaviorBase is a convenience base class that provides a default implementation of the
Behavior contract. It also provides behavior listener registration and state saving support.
| Constructor and Description |
|---|
BehaviorBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addBehaviorListener(BehaviorListener listener)
Add the specified |
void |
broadcast(BehaviorEvent event)
Default implementation of |
void |
clearInitialState()
Clears the initial state flag, causing the behavior to revert from partial to full state saving. |
boolean |
initialStateMarked()
Implementation of |
boolean |
isTransient()
Implementation of |
void |
markInitialState()
Implementation of |
protected void |
removeBehaviorListener(BehaviorListener listener)
Remove the specified |
void |
restoreState(FacesContext context,
java.lang.Object state)
|
java.lang.Object |
saveState(FacesContext context)
Implementation of |
void |
setTransient(boolean transientFlag)
Implementation of |
public void broadcast(BehaviorEvent event) throws AbortProcessingException
Default implementation of Behavior.broadcast(jakarta.faces.event.BehaviorEvent). Delivers the specified BehaviorEvent to all registered
BehaviorListener event listeners who have expressed an interest in events of this type. Listeners are called
in the order in which they were registered (added).
broadcast in interface Behaviorevent - The BehaviorEvent to be broadcastAbortProcessingException - Signal the Jakarta Server Faces implementation that no further processing on the
current event should be performedjava.lang.IllegalArgumentException - if the implementation class of this BehaviorEvent is not supported by this
componentjava.lang.NullPointerException - if event is nullpublic boolean isTransient()
Implementation of StateHolder.isTransient().
isTransient in interface StateHoldertrue if transient, false otherwise.public void setTransient(boolean transientFlag)
Implementation of StateHolder.setTransient(boolean).
setTransient in interface StateHoldertransientFlag - boolean pass true if this Object will
not participate in state saving or restoring, otherwise pass false.public java.lang.Object saveState(FacesContext context)
Implementation of StateHolder.saveState(jakarta.faces.context.FacesContext).
saveState in interface StateHoldercontext - the Faces context.public void restoreState(FacesContext context, java.lang.Object state)
restoreState in interface StateHoldercontext - the Faces context.state - the state.public void markInitialState()
Implementation of PartialStateHolder.markInitialState().
markInitialState in interface PartialStateHolderpublic boolean initialStateMarked()
Implementation of PartialStateHolder.initialStateMarked().
initialStateMarked in interface PartialStateHoldertrue if the initial state is marked, false otherwise.public void clearInitialState()
Clears the initial state flag, causing the behavior to revert from partial to full state saving.
clearInitialState in interface PartialStateHolderprotected void addBehaviorListener(BehaviorListener listener)
Add the specified BehaviorListener to the set of listeners registered to receive event notifications from
this Behavior. It is expected that Behavior classes acting as event sources will have corresponding
typesafe APIs for registering listeners of the required type, and the implementation of those registration methods
will delegate to this method. For example:
public class AjaxBehaviorEvent extends BehaviorEvent { ... }
public interface AjaxBehaviorListener extends BehaviorListener {
public void processAjaxBehavior(FooEvent event);
}
public class AjaxBehavior extends ClientBehaviorBase {
...
public void addAjaxBehaviorListener(AjaxBehaviorListener listener) {
addBehaviorListener(listener);
}
public void removeAjaxBehaviorListener(AjaxBehaviorListener listener) {
removeBehaviorListener(listener);
}
...
}
listener - The BehaviorListener to be registeredjava.lang.NullPointerException - if listener is nullprotected void removeBehaviorListener(BehaviorListener listener)
Remove the specified BehaviorListener from the set of listeners registered to receive event notifications
from this Behavior.
listener - The BehaviorListener to be deregisteredjava.lang.NullPointerException - if listener is null