org.apache.myfaces.application
Class StateCache<K,V>

java.lang.Object
  extended by org.apache.myfaces.application.StateCache<K,V>

public abstract class StateCache<K,V>
extends Object

This class provides and interface to separate the state caching operations (saving/restoring) from the renderkit specific stuff that HtmlResponseStateManager should do.

Author:
Leonardo Uribe

Constructor Summary
StateCache()
           
 
Method Summary
abstract  K encodeSerializedState(FacesContext facesContext, Object serializedView)
          Calculate the token to be used if server side state saving, or encode the view and return the viewState that can be used by the underlying ResponseStateManager to write the state.
abstract  boolean isWriteStateAfterRenderViewRequired(FacesContext facesContext)
          Indicates if the call to ResponseStateManager.writeState should be done after the view is fully rendered.
abstract  V restoreSerializedView(FacesContext facesContext, String viewId, K viewState)
          Get the state from the cache is server side state saving is used, or decode it from the passed viewState param if client side is used.
abstract  K saveSerializedView(FacesContext facesContext, V serializedView)
          Put the state on the cache, to can be restored later.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateCache

public StateCache()
Method Detail

saveSerializedView

public abstract K saveSerializedView(FacesContext facesContext,
                                     V serializedView)
Put the state on the cache, to can be restored later.

Parameters:
facesContext -
serializedView -

restoreSerializedView

public abstract V restoreSerializedView(FacesContext facesContext,
                                        String viewId,
                                        K viewState)
Get the state from the cache is server side state saving is used, or decode it from the passed viewState param if client side is used.

Parameters:
facesContext -
viewId - The viewId of the view to be restored
viewState - A token usually retrieved from a call to ResponseStateManager.getState that will be used to identify or restore the state.
Returns:

encodeSerializedState

public abstract K encodeSerializedState(FacesContext facesContext,
                                        Object serializedView)
Calculate the token to be used if server side state saving, or encode the view and return the viewState that can be used by the underlying ResponseStateManager to write the state.

Parameters:
facesContext -
state - The state that will be used to derive the token returned.
Returns:
A token (usually encoded on javax.faces.ViewState input hidden field) that will be passed to ResponseStateManager.writeState or ResponseStateManager.getViewState to be output to the client.

isWriteStateAfterRenderViewRequired

public abstract boolean isWriteStateAfterRenderViewRequired(FacesContext facesContext)
Indicates if the call to ResponseStateManager.writeState should be done after the view is fully rendered. Usually this is required for client side state saving, but it is not for server side state saving, because ResponseStateManager.writeState could render a just a marker and then StateManager.saveState could be called, preventing use an additional buffer.

Parameters:
facesContext -
Returns:


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