Top Description Methods
javax.faces.component

public Interface StateHolder

Known Direct Subinterfaces
javax.faces.component.PartialStateHolder, javax.faces.component.StateHelper
Known Direct Implementers
javax.faces.component.UIComponent.ComponentSystemEventListenerAdapter, javax.faces.component.UINamingContainer, javax.faces.event.MethodExpressionActionListener, javax.faces.event.MethodExpressionValueChangeListener, javax.faces.validator.MethodExpressionValidator, com.sun.faces.application.MethodBindingMethodExpressionAdapter, com.sun.faces.application.MethodExpressionMethodBindingAdapter, com.sun.faces.application.ValueBindingValueExpressionAdapter, com.sun.faces.application.ValueExpressionValueBindingAdapter, com.sun.faces.cdi.CdiBehavior, com.sun.faces.cdi.CdiConverter, com.sun.faces.cdi.CdiValidator, com.sun.faces.facelets.tag.composite.RelocateListener, com.sun.faces.taglib.jsf_core.ConverterTag.BindingConverter, com.sun.faces.taglib.jsf_core.SetPropertyActionListenerImpl, com.sun.faces.taglib.jsf_core.ValidatorTag.BindingValidator, com.sun.faces.util.ComponentStruct, javax.faces.component.MethodBindingValidator, javax.faces.component.MethodBindingValueChangeListener
Imports
javax.faces.context.FacesContext

This interface is implemented by classes that need to save their state between requests.

An implementor must implement both saveState and restoreState methods in this class, since these two methods have a tightly coupled contract between themselves. In other words, if there is an ineritance hierarchy, it is not permissable to have the saveState and restoreState methods reside at different levels of the hierarchy.

An implementor must have a public no-args constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if transient, false otherwise.
isTransient
()

If true, the Object implementing this interface must not participate in state saving or restoring.

public void
restoreState(FacesContext
the Faces context.
context
,
Object
the state.
state
)

Perform any processing required to restore the state from the entries in the state Object.

public Object

Returns:

the saved state.
saveState
(FacesContext
the Faces context.
context
)

Gets the state of the instance as a Serializable Object.

public void
setTransient(boolean
boolean pass true if this Object will not participate in state saving or restoring, otherwise pass false.
newTransientValue
)

Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.

Method Detail

isTransientback to summary
public boolean isTransient()

If true, the Object implementing this interface must not participate in state saving or restoring.

Returns:boolean

true if transient, false otherwise.

restoreStateback to summary
public void restoreState(FacesContext context, Object state)

Perform any processing required to restore the state from the entries in the state Object.

If the class that implements this interface has references to instances that also implement StateHolder (such as a UIComponent with event handlers, validators, etc.) this method must call the restoreState method on all those instances as well.

If the state argument is null, take no action and return.

Parameters
context:FacesContext

the Faces context.

state:Object

the state.

Exceptions
NullPointerException:
if context is null.
saveStateback to summary
public Object saveState(FacesContext context)

Gets the state of the instance as a Serializable Object.

If the class that implements this interface has references to instances that implement StateHolder (such as a UIComponent with event handlers, validators, etc.) this method must call the saveState method on all those instances as well. This method must not save the state of children and facets. That is done via the javax.faces.application.StateManager

This method must not alter the state of the implementing object. In other words, after executing this code:


Object state = component.saveState(facesContext);

component should be the same as before executing it.

The return from this method must be Serializable

Parameters
context:FacesContext

the Faces context.

Returns:Object

the saved state.

Exceptions
NullPointerException:
if context is null
setTransientback to summary
public void setTransient(boolean newTransientValue)

Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.

Parameters
newTransientValue:boolean

boolean pass true if this Object will not participate in state saving or restoring, otherwise pass false.