Class BehaviorBase
- java.lang.Object
-
- javax.faces.component.behavior.BehaviorBase
-
- All Implemented Interfaces:
Behavior,PartialStateHolder,StateHolder
- Direct Known Subclasses:
ClientBehaviorBase
public class BehaviorBase extends java.lang.Object implements Behavior, PartialStateHolder
BehaviorBase is a convenience base class that provides a default implementation of the
Behaviorcontract. It also provides behavior listener registration and state saving support.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description BehaviorBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddBehaviorListener(BehaviorListener listener)Add the specifiedBehaviorListenerto the set of listeners registered to receive event notifications from thisBehavior.voidbroadcast(BehaviorEvent event)Default implementation ofBehavior.broadcast(javax.faces.event.BehaviorEvent).voidclearInitialState()Clears the initial state flag, causing the behavior to revert from partial to full state saving.booleaninitialStateMarked()Implementation ofPartialStateHolder.initialStateMarked().booleanisTransient()Implementation ofStateHolder.isTransient().voidmarkInitialState()Implementation ofPartialStateHolder.markInitialState().protected voidremoveBehaviorListener(BehaviorListener listener)Remove the specifiedBehaviorListenerfrom the set of listeners registered to receive event notifications from thisBehavior.voidrestoreState(FacesContext context, java.lang.Object state)Implementation ofStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object).java.lang.ObjectsaveState(FacesContext context)Implementation ofStateHolder.saveState(javax.faces.context.FacesContext).voidsetTransient(boolean transientFlag)Implementation ofStateHolder.setTransient(boolean).
-
-
-
Method Detail
-
broadcast
public void broadcast(BehaviorEvent event) throws AbortProcessingException
Default implementation of
Behavior.broadcast(javax.faces.event.BehaviorEvent). Delivers the specifiedBehaviorEventto all registeredBehaviorListenerevent listeners who have expressed an interest in events of this type. Listeners are called in the order in which they were registered (added).- Specified by:
broadcastin interfaceBehavior- Parameters:
event- TheBehaviorEventto be broadcast- Throws:
AbortProcessingException- Signal the JavaServer Faces implementation that no further processing on the current event should be performedjava.lang.IllegalArgumentException- if the implementation class of thisBehaviorEventis not supported by this componentjava.lang.NullPointerException- ifeventisnull- Since:
- 2.0
-
isTransient
public boolean isTransient()
Implementation of
StateHolder.isTransient().- Specified by:
isTransientin interfaceStateHolder
-
setTransient
public void setTransient(boolean transientFlag)
Implementation of
StateHolder.setTransient(boolean).- Specified by:
setTransientin interfaceStateHolder- Parameters:
transientFlag- boolean passtrueif this Object will not participate in state saving or restoring, otherwise passfalse.
-
saveState
public java.lang.Object saveState(FacesContext context)
Implementation of
StateHolder.saveState(javax.faces.context.FacesContext).- Specified by:
saveStatein interfaceStateHolder
-
restoreState
public void restoreState(FacesContext context, java.lang.Object state)
Implementation of
StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object).- Specified by:
restoreStatein interfaceStateHolder
-
markInitialState
public void markInitialState()
Implementation of
PartialStateHolder.markInitialState().- Specified by:
markInitialStatein interfacePartialStateHolder
-
initialStateMarked
public boolean initialStateMarked()
Implementation of
PartialStateHolder.initialStateMarked().- Specified by:
initialStateMarkedin interfacePartialStateHolder
-
clearInitialState
public void clearInitialState()
Clears the initial state flag, causing the behavior to revert from partial to full state saving.
- Specified by:
clearInitialStatein interfacePartialStateHolder
-
addBehaviorListener
protected void addBehaviorListener(BehaviorListener listener)
Add the specified
BehaviorListenerto the set of listeners registered to receive event notifications from thisBehavior. It is expected thatBehaviorclasses 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); } ... }- Parameters:
listener- TheBehaviorListenerto be registered- Throws:
java.lang.NullPointerException- iflistenerisnull- Since:
- 2.0
-
removeBehaviorListener
protected void removeBehaviorListener(BehaviorListener listener)
Remove the specified
BehaviorListenerfrom the set of listeners registered to receive event notifications from thisBehavior.- Parameters:
listener- TheBehaviorListenerto be deregistered- Throws:
java.lang.NullPointerException- iflistenerisnull- Since:
- 2.0
-
-