- java.lang.Object
-
- javax.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 and Description BehaviorBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description protected void
addBehaviorListener(BehaviorListener listener)
Add the specified
BehaviorListener
to the set of listeners registered to receive event notifications from thisBehavior
.void
broadcast(BehaviorEvent event)
Default implementation of
Behavior.broadcast(javax.faces.event.BehaviorEvent)
.void
clearInitialState()
Clears the initial state flag, causing the behavior to revert from partial to full state saving.
boolean
initialStateMarked()
Implementation of
PartialStateHolder.initialStateMarked()
.boolean
isTransient()
Implementation of
StateHolder.isTransient()
.void
markInitialState()
Implementation of
PartialStateHolder.markInitialState()
.protected void
removeBehaviorListener(BehaviorListener listener)
Remove the specified
BehaviorListener
from the set of listeners registered to receive event notifications from thisBehavior
.void
restoreState(FacesContext context, Object state)
Implementation of
StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
.Object
saveState(FacesContext context)
Implementation of
StateHolder.saveState(javax.faces.context.FacesContext)
.void
setTransient(boolean transientFlag)
Implementation of
StateHolder.setTransient(boolean)
.
-
-
-
Method Detail
-
broadcast
public void broadcast(BehaviorEvent event) throws AbortProcessingException
Default implementation of
Behavior.broadcast(javax.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 JavaServer 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
-
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(javax.faces.context.FacesContext)
.- Specified by:
saveState
in interfaceStateHolder
-
restoreState
public void restoreState(FacesContext context, Object state)
Implementation of
StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
.- Specified by:
restoreState
in interfaceStateHolder
-
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
-
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
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/faces/component/behavior/behaviorbase.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.