Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.faces.render
Class ResponseStateManager

    java.lang.Object
      javax.faces.render.ResponseStateManager

    public abstract class ResponseStateManager

extends java.lang.Object

ResponseStateManager is the helper class to `StateManager` that knows the specific rendering technology being used to generate the response. It is a singleton abstract class, vended by the `RenderKit`. This class knows the mechanics of saving state, whether it be in hidden fields, session, or some combination of the two.

Field Summary
`static java.lang.String` | `RENDER_KIT_ID_PARAM` The name of the request parameter used by the default implementation of `ViewHandler.calculateRenderKitId(javax.faces.context.FacesContext)` to derive a RenderKit ID.
`static java.lang.String` | `VIEW_STATE_PARAM` Implementations must use this value as the name and id of the client parameter in which to save the state between requests.

Constructor Summary
`ResponseStateManager()`

Method Summary
`java.lang.Object` | `getComponentStateToRestore(FacesContext context)` Deprecated. This method has been replaced by `getState(javax.faces.context.FacesContext, java.lang.String)`. The default implementation returns `null`.
`java.lang.Object` | `getState(FacesContext context, java.lang.String viewId)` The implementation must inspect the current request and return an Object representing the tree structure and component state passed in to a previous invocation of `writeState(javax.faces.context.FacesContext,java.lang.Object)`.
`java.lang.Object` | `getTreeStructureToRestore(FacesContext context, java.lang.String viewId)` Deprecated. This method has been replaced by `getState(javax.faces.context.FacesContext, java.lang.String)`. The default implementation returns `null`.
`java.lang.String` | `getViewState(FacesContext context, java.lang.Object state)` Return the specified state as a `String` without any markup related to the rendering technology supported by this ResponseStateManager.
`boolean` | `isPostback(FacesContext context)` Return true if the current request is a postback.
`void` | `writeState(FacesContext context, java.lang.Object state)`
`void` | `writeState(FacesContext context, StateManager.SerializedView state)` Deprecated. This method has been replaced by `writeState(javax.faces.context.FacesContext,java.lang.Object)`. The default implementation creates a two element `Object` array with the first element being the return from calling `StateManager.SerializedView.getStructure()`, and the second being the return from `StateManager.SerializedView.getState()`. It then passes this `Object` array to `writeState(javax.faces.context.FacesContext, java.lang.Object)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### RENDER_KIT_ID_PARAM

    public static final java.lang.String RENDER_KIT_ID_PARAM

  The name of the request parameter used by the default implementation of `ViewHandler.calculateRenderKitId(javax.faces.context.FacesContext)` to derive a RenderKit ID.

  See Also:
    Constant Field Values

### VIEW_STATE_PARAM

    public static final java.lang.String VIEW_STATE_PARAM

  Implementations must use this value as the name and id of the client parameter in which to save the state between requests.

  It is strongly recommend that implementations guard against cross site scripting attacks by at least making the value of this parameter difficult to predict.

  Since:
    1.2
  See Also:
    Constant Field Values

Constructor Detail

### ResponseStateManager

    public ResponseStateManager()

Method Detail

### writeState

    public void writeState(FacesContext context,
                           java.lang.Object state)
                    throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeState

    public void writeState(FacesContext context,
                           StateManager.SerializedView state)
                    throws java.io.IOException

  Deprecated. This method has been replaced by `writeState(javax.faces.context.FacesContext,java.lang.Object)`. The default implementation creates a two element `Object` array with the first element being the return from calling `StateManager.SerializedView.getStructure()`, and the second being the return from `StateManager.SerializedView.getState()`. It then passes this `Object` array to `writeState(javax.faces.context.FacesContext, java.lang.Object)`.

  Take the argument `state` and write it into the output using the current `ResponseWriter`, which must be correctly positioned already.

  If the `StateManager.SerializedView` is to be written out to hidden fields, the implementation must take care to make all necessary character replacements to make the Strings suitable for inclusion as an HTTP request paramater.

  If the state saving method for this application is `StateManager.STATE_SAVING_METHOD_CLIENT`, the implementation may encrypt the state to be saved to the client. We recommend that the state be unreadable by the client, and also be tamper evident. The reference implementation follows these recommendations.

  Parameters:
    `context` - The `FacesContext` instance for the current request
    `state` - The serialized state information previously saved
  Throws:
    `java.io.IOException`

### getState

    public java.lang.Object getState(FacesContext context,
                                     java.lang.String viewId)

  The implementation must inspect the current request and return an Object representing the tree structure and component state passed in to a previous invocation of `writeState(javax.faces.context.FacesContext,java.lang.Object)`.

  For backwards compatability with existing `ResponseStateManager` implementations, the default implementation of this method calls `getTreeStructureToRestore(javax.faces.context.FacesContext, java.lang.String)` and `getComponentStateToRestore(javax.faces.context.FacesContext)` and creates and returns a two element `Object` array with element zero containing the `structure` property and element one containing the `state` property of the `SerializedView`.

  Parameters:
    `context` - The `FacesContext` instance for the current request
    `viewId` - View identifier of the view to be restored
  Returns:
    the tree structure and component state Object passed in to `writeState`. If this is an initial request, this method returns `null`.
  Since:
    1.2

### getTreeStructureToRestore

    public java.lang.Object getTreeStructureToRestore(FacesContext context,
                                                      java.lang.String viewId)

  Deprecated. This method has been replaced by `getState(javax.faces.context.FacesContext, java.lang.String)`. The default implementation returns `null`.

  The implementation must inspect the current request and return the tree structure Object passed to it on a previous invocation of `writeState()`.

  Parameters:
    `context` - The `FacesContext` instance for the current request
    `viewId` - View identifier of the view to be restored

### getComponentStateToRestore

    public java.lang.Object getComponentStateToRestore(FacesContext context)

  Deprecated. This method has been replaced by `getState(javax.faces.context.FacesContext, java.lang.String)`. The default implementation returns `null`.

  The implementation must inspect the current request and return the component state Object passed to it on a previous invocation of `writeState()`.

  Parameters:
    `context` - The `FacesContext` instance for the current request

### isPostback

    public boolean isPostback(FacesContext context)

  Return true if the current request is a postback. This method is leveraged from the Restore View Phase to determine if `ViewHandler.restoreView(javax.faces.context.FacesContext, java.lang.String)` or `ViewHandler.createView(javax.faces.context.FacesContext, java.lang.String)` should be called. The default implementation must return `true` if this `ResponseStateManager` instance wrote out state on a previous request to which this request is a postback, `false` otherwise.

  The implementation if this method for the Standard HTML RenderKit must consult the `ExternalContext`'s `requestParameterMap` and return `true` if and only if there is a key equal to the value of the symbolic constant `VIEW_STATE_PARAM`.

  For backwards compatability with implementations of `ResponseStateManager` prior to JSF 1.2, a default implementation is provided that consults the `ExternalContext`'s `requestParameterMap` and return `true` if its size is greater than 0.

  Since:
    1.2

### getViewState

    public java.lang.String getViewState(FacesContext context,
                                         java.lang.Object state)

  Return the specified state as a `String` without any markup related to the rendering technology supported by this ResponseStateManager.

  Parameters:
    `context` - the `FacesContext` for the current request
    `state` - the state from which the String version will be generated from
  Returns:
    the view state for this request without any markup specifics
  Since:
    2.0

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2002-2010 Oracle America Inc, Inc. All Rights Reserved.