Class BehaviorBase
- java.lang.Object
-
- jakarta.faces.component.behavior.BehaviorBase
-
- All Implemented Interfaces:
Behavior,PartialStateHolder,StateHolder
- Direct Known Subclasses:
ClientBehaviorBase
public class BehaviorBase extends 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(jakarta.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, Object state)ObjectsaveState(FacesContext context)Implementation ofStateHolder.saveState(jakarta.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(jakarta.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 Jakarta Faces implementation that no further processing on the current event should be performedIllegalArgumentException- if the implementation class of thisBehaviorEventis not supported by this componentNullPointerException- ifeventisnull- Since:
- 2.0
-
isTransient
public boolean isTransient()
Implementation of
StateHolder.isTransient().- Specified by:
isTransientin interfaceStateHolder- Returns:
trueif transient,falseotherwise.
-
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 Object saveState(FacesContext context)
Implementation of
StateHolder.saveState(jakarta.faces.context.FacesContext).- Specified by:
saveStatein interfaceStateHolder- Parameters:
context- the Faces context.- Returns:
- the saved state.
-
restoreState
public void restoreState(FacesContext context, Object state)
- Specified by:
restoreStatein interfaceStateHolder- Parameters:
context- the Faces context.state- the state.
-
markInitialState
public void markInitialState()
Implementation of
PartialStateHolder.markInitialState().- Specified by:
markInitialStatein interfacePartialStateHolder
-
initialStateMarked
public boolean initialStateMarked()
Implementation of
PartialStateHolder.initialStateMarked().- Specified by:
initialStateMarkedin interfacePartialStateHolder- Returns:
trueif the initial state is marked,falseotherwise.
-
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:
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:
NullPointerException- iflistenerisnull- Since:
- 2.0
-
-