Top Description Fields Constructors Methods
com.sun.faces.renderkit

public Class ResponseStateManagerImpl

extends ResponseStateManager
Class Inheritance
Static Imports
com.sun.faces.config.WebConfiguration.WebContextInitParameter.StateSavingMethod, com.sun.faces.util.RequestStateManager.FACES_VIEW_STATE, jakarta.faces.application.StateManager.STATE_SAVING_METHOD_CLIENT

A ResonseStateManager implementation for the default HTML render kit.

Field Summary

Modifier and TypeField and Description
private StateHelper
Inherited from jakarta.faces.render.ResponseStateManager:
CLIENT_WINDOW_PARAMCLIENT_WINDOW_URL_PARAMNON_POSTBACK_VIEW_TOKEN_PARAMRENDER_KIT_ID_PARAMVIEW_STATE_PARAM

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getCryptographicallyStrongTokenFromSession(FacesContext
the FacesContext for the current request
context
)

Overrides jakarta.faces.render.ResponseStateManager.getCryptographicallyStrongTokenFromSession.

Compliant implementations must return a cryptographically strong token for use to protect views in this application.

public Object
getState(FacesContext
The FacesContext instance for the current request
context
,
String
View identifier of the view to be restored
viewId
)

Overrides jakarta.faces.render.ResponseStateManager.getState.

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(jakarta.faces.context.FacesContext, java.lang.Object).

public String
getViewState(FacesContext
the FacesContext for the current request
context
,
Object
the state from which the String version will be generated from
state
)

Overrides jakarta.faces.render.ResponseStateManager.getViewState.

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

public boolean
isPostback(FacesContext
the FacesContext for the current request.
context
)

Overrides jakarta.faces.render.ResponseStateManager.isPostback.

Return true if the current request is a postback.

public boolean

Returns:

true if "stateless" was found, false otherwise.
isStateless
(FacesContext
the Faces context.
facesContext
,
String
the view id.
viewId
)

Overrides jakarta.faces.render.ResponseStateManager.isStateless.

If the preceding call to writeState(jakarta.faces.context.FacesContext, java.lang.Object) was stateless, return true.

public void
writeState(FacesContext
The FacesContext instance for the current request
context
,
Object
The serialized state information previously saved
state
)

Overrides jakarta.faces.render.ResponseStateManager.writeState.

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

Field Detail

helperback to summary
private StateHelper helper

Constructor Detail

ResponseStateManagerImplback to summary
public ResponseStateManagerImpl()

Method Detail

getCryptographicallyStrongTokenFromSessionback to summary
public String getCryptographicallyStrongTokenFromSession(FacesContext context)

Overrides jakarta.faces.render.ResponseStateManager.getCryptographicallyStrongTokenFromSession.

Doc from jakarta.faces.render.ResponseStateManager.getCryptographicallyStrongTokenFromSession.

Compliant implementations must return a cryptographically strong token for use to protect views in this application. For backwards compatibility with earlier revisions, a default implementation is provided that simply returns null.

Parameters
context:FacesContext

the FacesContext for the current request

Returns:String

a cryptographically strong value

Annotations
@Override
getStateback to summary
public Object getState(FacesContext context, String viewId)

Overrides jakarta.faces.render.ResponseStateManager.getState.

Doc from jakarta.faces.render.ResponseStateManager.getState.

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(jakarta.faces.context.FacesContext, java.lang.Object).

If the state saving method for this application is jakarta.faces.application.StateManager#STATE_SAVING_METHOD_CLIENT, writeState() will have encrypted the state in a tamper evident manner. If the state fails to decrypt, or decrypts but indicates evidence of tampering, a jakarta.faces.application.ProtectedViewException must be thrown.

Parameters
context:FacesContext

The FacesContext instance for the current request

viewId:String

View identifier of the view to be restored

Returns:Object

the tree structure and component state Object passed in to writeState. If this is an initial request, this method returns null.

Annotations
@Override
See Also
ResponseStateManager#getState(jakarta.faces.context.FacesContext, java.lang.String)
getViewStateback to summary
public String getViewState(FacesContext context, Object state)

Overrides jakarta.faces.render.ResponseStateManager.getViewState.

Doc from jakarta.faces.render.ResponseStateManager.getViewState.

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

Parameters
context:FacesContext

the FacesContext for the current request

state:Object

the state from which the String version will be generated from

Returns:String

the view state for this request without any markup specifics

Annotations
@Override
See Also
ResponseStateManager#getViewState(jakarta.faces.context.FacesContext, java.lang.Object)
isPostbackback to summary
public boolean isPostback(FacesContext context)

Overrides jakarta.faces.render.ResponseStateManager.isPostback.

Doc from jakarta.faces.render.ResponseStateManager.isPostback.

Return true if the current request is a postback. This method is leveraged from the Restore View Phase to determine if jakarta.faces.application.ViewHandler#restoreView or jakarta.faces.application.ViewHandler#createView 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 of this method for the Standard HTML RenderKit must consult the jakarta.faces.context.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 compatibility with implementations of ResponseStateManager prior to Jakarta Faces 1.2, a default implementation is provided that consults the jakarta.faces.context.ExternalContext's requestParameterMap and return true if its size is greater than 0.

Parameters
context:FacesContext

the FacesContext for the current request.

Returns:boolean

the value as specified above

Annotations
@Override
See Also
ResponseStateManager#isPostback(jakarta.faces.context.FacesContext)
isStatelessback to summary
public boolean isStateless(FacesContext facesContext, String viewId)

Overrides jakarta.faces.render.ResponseStateManager.isStateless.

Doc from jakarta.faces.render.ResponseStateManager.isStateless.

If the preceding call to writeState(jakarta.faces.context.FacesContext, java.lang.Object) was stateless, return true. If the preceding call to writeState() was stateful, return false. Otherwise throw IllegalStateException.

To preserve backward compatibility with custom implementations that may have extended from an earlier version of this class, an implementation is provided that returns false. A compliant implementation must override this method to take the specified action.

Parameters
facesContext:FacesContext

the Faces context.

viewId:String

the view id.

Returns:boolean

true if "stateless" was found, false otherwise.

Annotations
@Override
Exceptions
IllegalStateException:
when the request is not a postback.
writeStateback to summary
public void writeState(FacesContext context, Object state) throws IOException

Overrides jakarta.faces.render.ResponseStateManager.writeState.

Doc from jakarta.faces.render.ResponseStateManager.writeState.

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

Call FacesContext#getViewRoot(). If jakarta.faces.component.UIComponent#isTransient() returns true, take implementation specific action so that the following call to isStateless returns true and return. Otherwise, proceed as follows.

If the state 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 jakarta.faces.application.StateManager#STATE_SAVING_METHOD_CLIENT, the implementation must encrypt the state to be saved to the client in a tamper evident manner.

If the state saving method for this application is jakarta.faces.application.StateManager#STATE_SAVING_METHOD_SERVER, and the current request is an Ajax request jakarta.faces.context.PartialViewContext#isAjaxRequest returns true), use the current view state identifier if it is available (do not generate a new identifier).

Write out the render kit identifier associated with this ResponseStateManager implementation with the name as the value of the String constant ResponseStateManager.RENDER_KIT_ID_PARAM. The render kit identifier must not be written if:

The jakarta.faces.lifecycle.ClientWindow must be written using these steps. Call jakarta.faces.context.ExternalContext#getClientWindow. If the result is null, take no further action regarding the ClientWindow. If the result is non-null, write a hidden field whose name is CLIENT_WINDOW_PARAM and whose id is <VIEW_ROOT_CONTAINER_CLIENT_ID><SEP>jakarta.faces.ClientWindow<SEP><UNIQUE_PER_VIEW_NUMBER> where <SEP> is the currently configured UINamingContainer.getSeparatorChar(). <VIEW_ROOT_CONTAINER_CLIENT_ID> is the return from UIViewRoot.getContainerClientId() on the view from whence this state originated. <UNIQUE_PER_VIEW_NUMBER> is a number that must be unique within this view, but must not be included in the view state. The value of the field is implementation dependent but must uniquely identify this window within the user's session.

Parameters
context:FacesContext

The FacesContext instance for the current request

state:Object

The serialized state information previously saved

Annotations
@Override
Exceptions
IOException:
if the state argument is not an array of length 2.
See Also
ResponseStateManager#writeState(jakarta.faces.context.FacesContext, java.lang.Object)