org.apache.myfaces.trinidadinternal.application
Class StateManagerImpl

java.lang.Object
  extended by javax.faces.application.StateManager
      extended by javax.faces.application.StateManagerWrapper
          extended by org.apache.myfaces.trinidadinternal.application.StateManagerImpl
All Implemented Interfaces:
javax.faces.FacesWrapper<javax.faces.application.StateManager>

public class StateManagerImpl
extends javax.faces.application.StateManagerWrapper

StateManager that handles a hybrid client/server strategy: the state is stored on the server, and only a small token is stored on the client.

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/application/StateManagerImpl.java#2 $) $Date: 18-nov-2005.16:12:04 $

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.faces.application.StateManager
javax.faces.application.StateManager.SerializedView
 
Field Summary
static java.lang.String CACHE_VIEW_ROOT_INIT_PARAM
           
static java.lang.String CLIENT_STATE_MAX_TOKENS_PARAM_NAME
          Servlet context initialization parameter used by StateManagerImpl to decide how many tokens can be stored per user.
static java.lang.String CLIENT_STATE_METHOD_ALL
          Value indicating that the entire component state will be stored on the client.
static java.lang.String CLIENT_STATE_METHOD_PARAM_NAME
          Servlet context initialization parameter used by StateManagerImpl to decide what sort of state should be saved on the client.
static java.lang.String CLIENT_STATE_METHOD_TOKEN
          Value indicating that only a simple token will be stored on the client.
static java.lang.String COMPRESS_VIEW_STATE_PARAM_NAME
          Servlet context initialization parameter used by StateManagerImpl to decide whether to zip state.
static java.lang.String RESPONSE_STATE_MANAGER_STATE_KEY
           
 
Fields inherited from class javax.faces.application.StateManager
FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME, PARTIAL_STATE_SAVING_PARAM_NAME, STATE_SAVING_METHOD_CLIENT, STATE_SAVING_METHOD_PARAM_NAME, STATE_SAVING_METHOD_SERVER
 
Constructor Summary
StateManagerImpl(javax.faces.application.StateManager delegate)
           
 
Method Summary
static void clearReuseRequestTokenForResponse(javax.faces.context.ExternalContext ec)
          Clears the flag indicating that the old request token should be used for the response.
static java.lang.String getActivePageToken(org.apache.myfaces.trinidad.context.RequestContext trinContext, javax.faces.context.ExternalContext external)
           
protected  java.lang.Object getComponentStateToSave(javax.faces.context.FacesContext context)
           
static java.lang.String getStateToken(javax.faces.context.FacesContext context)
           
protected  java.lang.Object getTreeStructureToSave(javax.faces.context.FacesContext context)
           
 java.lang.String getViewState(javax.faces.context.FacesContext context)
           
 javax.faces.application.StateManager getWrapped()
           
 boolean isSavingStateInClient(javax.faces.context.FacesContext context)
           
static boolean isValidViewStateToken(javax.faces.context.ExternalContext external, java.lang.String token)
          Returns whether a token is a currently valid View State Token
static void pinStateToRequest(javax.faces.context.FacesContext context, java.lang.String stateToken)
          Requests that an old state token be "pinned" to the state of the current request.
static void remapViewState(javax.faces.context.ExternalContext external, java.lang.String windowId, java.lang.String token)
          Give a valid state token not associated with a window, change it to be associated with the specified window Id.
protected  void restoreComponentState(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewRoot, java.lang.String renderKitId)
           
static javax.faces.component.UIComponent restoreComponentTree(javax.faces.context.FacesContext context, java.lang.Object savedState)
          Take an object created by saveComponentTree() and instantiate it as a UIComponent.
protected  javax.faces.component.UIViewRoot restoreTreeStructure(javax.faces.context.FacesContext context, java.lang.String viewId, java.lang.String renderKitId)
           
 javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context, java.lang.String viewId, java.lang.String renderKitId)
           
static javax.faces.component.UIViewRoot restoreViewRoot(javax.faces.context.FacesContext context, java.lang.Object saved)
           
static void reuseRequestTokenForResponse(javax.faces.context.ExternalContext ec)
          Mark the the incoming request token should be used for the response
static java.lang.Object saveComponentTree(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Save a component tree as an Object.
 java.lang.Object saveView(javax.faces.context.FacesContext context)
           
static java.lang.Object saveViewRoot(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot root)
          Save a view root.
 void setPerViewStateSaving(java.lang.String perViewStateSaving)
          The given parameter (perViewStateSaving) indicates if we need to enable client- OR server-side state-saving for the current VIEW.
 
Methods inherited from class javax.faces.application.StateManagerWrapper
saveSerializedView, writeState, writeState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESPONSE_STATE_MANAGER_STATE_KEY

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

CACHE_VIEW_ROOT_INIT_PARAM

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

CLIENT_STATE_METHOD_PARAM_NAME

public static final java.lang.String CLIENT_STATE_METHOD_PARAM_NAME
Servlet context initialization parameter used by StateManagerImpl to decide what sort of state should be saved on the client. Valid values are "token" and "all"; the default is "token".

See Also:
Constant Field Values

CLIENT_STATE_MAX_TOKENS_PARAM_NAME

public static final java.lang.String CLIENT_STATE_MAX_TOKENS_PARAM_NAME
Servlet context initialization parameter used by StateManagerImpl to decide how many tokens can be stored per user. The default is 15.

See Also:
Constant Field Values

COMPRESS_VIEW_STATE_PARAM_NAME

public static final java.lang.String COMPRESS_VIEW_STATE_PARAM_NAME
Servlet context initialization parameter used by StateManagerImpl to decide whether to zip state. Valid values are true and false

See Also:
Constant Field Values

CLIENT_STATE_METHOD_TOKEN

public static final java.lang.String CLIENT_STATE_METHOD_TOKEN
Value indicating that only a simple token will be stored on the client.

See Also:
Constant Field Values

CLIENT_STATE_METHOD_ALL

public static final java.lang.String CLIENT_STATE_METHOD_ALL
Value indicating that the entire component state will be stored on the client.

See Also:
Constant Field Values
Constructor Detail

StateManagerImpl

public StateManagerImpl(javax.faces.application.StateManager delegate)
Method Detail

getWrapped

public javax.faces.application.StateManager getWrapped()
Specified by:
getWrapped in interface javax.faces.FacesWrapper<javax.faces.application.StateManager>
Overrides:
getWrapped in class javax.faces.application.StateManagerWrapper

getViewState

public java.lang.String getViewState(javax.faces.context.FacesContext context)
Overrides:
getViewState in class javax.faces.application.StateManagerWrapper

saveView

public java.lang.Object saveView(javax.faces.context.FacesContext context)
Overrides:
saveView in class javax.faces.application.StateManagerWrapper

saveComponentTree

public static java.lang.Object saveComponentTree(javax.faces.context.FacesContext context,
                                                 javax.faces.component.UIComponent component)
Save a component tree as an Object.


restoreComponentTree

public static javax.faces.component.UIComponent restoreComponentTree(javax.faces.context.FacesContext context,
                                                                     java.lang.Object savedState)
                                                              throws java.lang.ClassNotFoundException,
                                                                     java.lang.InstantiationException,
                                                                     java.lang.IllegalAccessException
Take an object created by saveComponentTree() and instantiate it as a UIComponent.

Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

saveViewRoot

public static java.lang.Object saveViewRoot(javax.faces.context.FacesContext context,
                                            javax.faces.component.UIViewRoot root)
Save a view root. Doesn't return a SerializedView because SerializedView is a non-static inner class, and this needs to be a static method.


restoreViewRoot

public static javax.faces.component.UIViewRoot restoreViewRoot(javax.faces.context.FacesContext context,
                                                               java.lang.Object saved)
                                                        throws java.lang.ClassNotFoundException,
                                                               java.lang.InstantiationException,
                                                               java.lang.IllegalAccessException
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

getActivePageToken

public static java.lang.String getActivePageToken(org.apache.myfaces.trinidad.context.RequestContext trinContext,
                                                  javax.faces.context.ExternalContext external)

pinStateToRequest

public static void pinStateToRequest(javax.faces.context.FacesContext context,
                                     java.lang.String stateToken)
Requests that an old state token be "pinned" to the state of the current request. This means that the view state corresponding to the token will not be released before the state for this request is released.


getStateToken

public static java.lang.String getStateToken(javax.faces.context.FacesContext context)
Returns:
the state token for the current request

reuseRequestTokenForResponse

public static void reuseRequestTokenForResponse(javax.faces.context.ExternalContext ec)
Mark the the incoming request token should be used for the response


clearReuseRequestTokenForResponse

public static void clearReuseRequestTokenForResponse(javax.faces.context.ExternalContext ec)
Clears the flag indicating that the old request token should be used for the response.


isValidViewStateToken

public static boolean isValidViewStateToken(javax.faces.context.ExternalContext external,
                                            java.lang.String token)
Returns whether a token is a currently valid View State Token

Parameters:
external - The ExternalContext
token - The state token to check for validity
Returns:

remapViewState

public static void remapViewState(javax.faces.context.ExternalContext external,
                                  java.lang.String windowId,
                                  java.lang.String token)
Give a valid state token not associated with a window, change it to be associated with the specified window Id.

Parameters:
external - The ExternalContext
windowId - window id to store the state token under
token - The state token to remap from windowless to windowed

restoreView

public javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context,
                                                    java.lang.String viewId,
                                                    java.lang.String renderKitId)
Overrides:
restoreView in class javax.faces.application.StateManagerWrapper

setPerViewStateSaving

public void setPerViewStateSaving(java.lang.String perViewStateSaving)
The given parameter (perViewStateSaving) indicates if we need to enable client- OR server-side state-saving for the current VIEW.

This is an internal method, that is ONLY called by the Trinidad Document

Parameters:
perViewStateSaving - default, server or client for stateSaving

isSavingStateInClient

public boolean isSavingStateInClient(javax.faces.context.FacesContext context)
Overrides:
isSavingStateInClient in class javax.faces.application.StateManagerWrapper

getTreeStructureToSave

protected java.lang.Object getTreeStructureToSave(javax.faces.context.FacesContext context)
Overrides:
getTreeStructureToSave in class javax.faces.application.StateManagerWrapper

getComponentStateToSave

protected java.lang.Object getComponentStateToSave(javax.faces.context.FacesContext context)
Overrides:
getComponentStateToSave in class javax.faces.application.StateManagerWrapper

restoreTreeStructure

protected javax.faces.component.UIViewRoot restoreTreeStructure(javax.faces.context.FacesContext context,
                                                                java.lang.String viewId,
                                                                java.lang.String renderKitId)
Overrides:
restoreTreeStructure in class javax.faces.application.StateManagerWrapper

restoreComponentState

protected void restoreComponentState(javax.faces.context.FacesContext context,
                                     javax.faces.component.UIViewRoot viewRoot,
                                     java.lang.String renderKitId)
Overrides:
restoreComponentState in class javax.faces.application.StateManagerWrapper


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