Class UISaveState

  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIParameter
              extended by org.apache.myfaces.custom.savestate.UISaveState
All Implemented Interfaces:

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:

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.

$Revision: 705343 $ $Date: 2008-10-16 15:05:11 -0500 (Thu, 16 Oct 2008) $
Manfred Geiler (latest modification by $Author: skitching $)

Field Summary
static String COMPONENT_TYPE
Fields inherited from class javax.faces.component.UIComponent
Constructor Summary
          Construct an instance of the UISaveState.
Method Summary
 String getFamily()
 void restoreState(javax.faces.context.FacesContext context, Object state)
 Object saveState(javax.faces.context.FacesContext context)
Methods inherited from class javax.faces.component.UIParameter
getName, getValue, 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, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendererType, setTransient, setValueBinding
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression, setValueExpression
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final String COMPONENT_FAMILY
See Also:
Constant Field Values


public static final String COMPONENT_TYPE
See Also:
Constant Field Values
Constructor Detail


public UISaveState()
Construct an instance of the UISaveState.

Method Detail


public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
saveState in class javax.faces.component.UIParameter


public void restoreState(javax.faces.context.FacesContext context,
                         Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
restoreState in class javax.faces.component.UIParameter


public String getFamily()
getFamily in class javax.faces.component.UIParameter

Copyright © 2012 The Apache Software Foundation. All Rights Reserved.