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:
java.util.EventListener, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder

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 java.lang.String COMPONENT_FAMILY
static java.lang.String COMPONENT_TYPE
Fields inherited from class javax.faces.component.UIComponent
Constructor Summary
          Construct an instance of the UISaveState.
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, isDisable, setDisable, setName, setRendered, setValue
Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, initialStateMarked, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendererType, setTransient, setValueBinding, visitTree
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final java.lang.String COMPONENT_FAMILY
See Also:
Constant Field Values


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


public UISaveState()
Construct an instance of the UISaveState.

Method Detail


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


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


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

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