Class BehaviorBase
- All Implemented Interfaces:
Behavior
,PartialStateHolder
,StateHolder
- Direct Known Subclasses:
ClientBehaviorBase
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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
Clears the initial state flag, causing the behavior to revert from partial to full state saving.boolean
Implementation ofPartialStateHolder.initialStateMarked()
.boolean
Implementation ofStateHolder.isTransient()
.void
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) saveState
(FacesContext context) Implementation ofStateHolder.saveState(jakarta.faces.context.FacesContext)
.void
setTransient
(boolean transientFlag) Implementation ofStateHolder.setTransient(boolean)
.
-
Constructor Details
-
BehaviorBase
public BehaviorBase()
-
-
Method Details
-
broadcast
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 Server 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
Implementation of
StateHolder.saveState(jakarta.faces.context.FacesContext)
.- Specified by:
saveState
in interfaceStateHolder
- Parameters:
context
- the Faces context.- Returns:
- the saved state.
-
restoreState
- 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
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
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
-