org.apache.myfaces.custom.savestate
Class UISaveState
java.lang.Object
javax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UIParameter
org.apache.myfaces.custom.savestate.UISaveState
- All Implemented Interfaces:
- javax.faces.component.StateHolder
public class UISaveState
- extends javax.faces.component.UIParameter
Provides the ability to store a model value inside the view's component tree.
JSF provides three scopes for managed beans and therefore all the model
objects that the managed beans reference: request, session, application.
However a common requirement is a way for a model object to have a scope
that is tied to the duration of the current view; that is longer than the
request scope but shorter than session scope.
This component simply holds a reference to an arbitrary object (specified
by the value property). Because this object is an ordinary component whose
scope is the current view, the reference to the model automatically has that
same scope.
When the value is an EL expression, then after the view is restored the
recreated target object is stored at the specified location.
The object being saved must either:
- implement java.io.Serializable, or
- implement javax.faces.component.StateHolder and have a default
constructor.
Note that the saved object can be "chained" from view to view
in order to extend its lifetime from a single view to a sequence
of views if desired. A UISaveState component with an EL expression
such as "#{someBean}" will save the object state after render, and
restore it on postback. If navigation occurs to some other view
and that view has a UISaveState component with the same EL expression
then the object will simply be saved into the new view, thus extending
its lifetime.
- Version:
- $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (Thu, 03 Jul 2008) $
- Author:
- Manfred Geiler (latest modification by $Author: skitching $)
Method Summary |
java.lang.String |
getFamily()
|
void |
restoreState(javax.faces.context.FacesContext context,
java.lang.Object state)
|
java.lang.Object |
saveState(javax.faces.context.FacesContext context)
|
Methods inherited from class javax.faces.component.UIParameter |
getName, getValue, isRendered, setName, setRendered, setValue |
Methods inherited from class javax.faces.component.UIComponentBase |
addFacesListener, broadcast, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendererType, setTransient, setValueBinding |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
COMPONENT_TYPE
public static final java.lang.String COMPONENT_TYPE
- See Also:
- Constant Field Values
COMPONENT_FAMILY
public static final java.lang.String COMPONENT_FAMILY
- See Also:
- Constant Field Values
UISaveState
public UISaveState()
saveState
public java.lang.Object saveState(javax.faces.context.FacesContext context)
- Specified by:
saveState
in interface javax.faces.component.StateHolder
- Overrides:
saveState
in class javax.faces.component.UIParameter
restoreState
public void restoreState(javax.faces.context.FacesContext context,
java.lang.Object state)
- Specified by:
restoreState
in interface javax.faces.component.StateHolder
- Overrides:
restoreState
in class javax.faces.component.UIParameter
getFamily
public java.lang.String getFamily()
- Overrides:
getFamily
in class javax.faces.component.UIParameter
Copyright © 2010 The Apache Software Foundation. All Rights Reserved.