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
Behavior
contract. 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 void
addBehaviorListener(BehaviorListener listener)
Add the specifiedBehaviorListener
to the set of listeners registered to receive event notifications from thisBehavior
.void
broadcast(BehaviorEvent event)
Default implementation ofBehavior.broadcast(jakarta.faces.event.BehaviorEvent)
.void
clearInitialState()
Clears the initial state flag, causing the behavior to revert from partial to full state saving.boolean
initialStateMarked()
Implementation ofPartialStateHolder.initialStateMarked()
.boolean
isTransient()
Implementation ofStateHolder.isTransient()
.void
markInitialState()
Implementation ofPartialStateHolder.markInitialState()
.protected void
removeBehaviorListener(BehaviorListener listener)
Remove the specifiedBehaviorListener
from the set of listeners registered to receive event notifications from thisBehavior
.void
restoreState(FacesContext context, Object state)
Object
saveState(FacesContext context)
Implementation ofStateHolder.saveState(jakarta.faces.context.FacesContext)
.void
setTransient(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 specifiedBehaviorEvent
to all registeredBehaviorListener
event 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:
broadcast
in interfaceBehavior
- Parameters:
event
- TheBehaviorEvent
to 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 thisBehaviorEvent
is not supported by this componentNullPointerException
- ifevent
isnull
- Since:
- 2.0
-
isTransient
public boolean isTransient()
Implementation of
StateHolder.isTransient()
.- Specified by:
isTransient
in interfaceStateHolder
- Returns:
true
if transient,false
otherwise.
-
setTransient
public void setTransient(boolean transientFlag)
Implementation of
StateHolder.setTransient(boolean)
.- Specified by:
setTransient
in interfaceStateHolder
- Parameters:
transientFlag
- boolean passtrue
if 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:
saveState
in interfaceStateHolder
- Parameters:
context
- the Faces context.- Returns:
- the saved state.
-
restoreState
public void restoreState(FacesContext context, Object state)
- Specified by:
restoreState
in interfaceStateHolder
- Parameters:
context
- the Faces context.state
- the state.
-
markInitialState
public void markInitialState()
Implementation of
PartialStateHolder.markInitialState()
.- Specified by:
markInitialState
in interfacePartialStateHolder
-
initialStateMarked
public boolean initialStateMarked()
Implementation of
PartialStateHolder.initialStateMarked()
.- Specified by:
initialStateMarked
in interfacePartialStateHolder
- Returns:
true
if the initial state is marked,false
otherwise.
-
clearInitialState
public void clearInitialState()
Clears the initial state flag, causing the behavior to revert from partial to full state saving.
- Specified by:
clearInitialState
in interfacePartialStateHolder
-
addBehaviorListener
protected void addBehaviorListener(BehaviorListener listener)
Add the specified
BehaviorListener
to the set of listeners registered to receive event notifications from thisBehavior
. It is expected thatBehavior
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); } ... }
- Parameters:
listener
- TheBehaviorListener
to be registered- Throws:
NullPointerException
- iflistener
isnull
- Since:
- 2.0
-
removeBehaviorListener
protected void removeBehaviorListener(BehaviorListener listener)
Remove the specified
BehaviorListener
from the set of listeners registered to receive event notifications from thisBehavior
.- Parameters:
listener
- TheBehaviorListener
to be deregistered- Throws:
NullPointerException
- iflistener
isnull
- Since:
- 2.0
-
-