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

public Class ServerSideStateHelper

extends StateHelper
Class Inheritance
Static Imports
com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.AutoCompleteOffOnViewState, .WebConfiguration.BooleanWebContextInitParameter.EnableViewStateIdRendering, .WebConfiguration.BooleanWebContextInitParameter.GenerateUniqueServerStateIds, .WebConfiguration.BooleanWebContextInitParameter.SerializeServerState, .WebConfiguration.BooleanWebContextInitParameter.SerializeServerStateDeprecated, .WebConfiguration.WebContextInitParameter.NumberOfLogicalViews, .WebConfiguration.WebContextInitParameter.NumberOfViews, com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter.VIEW_STATE_PARAM

This StateHelper provides the functionality associated with server-side state saving, though in actuallity, it is a hybrid between client and server.

Field Summary

Modifier and TypeField and Description
protected boolean
generateUniqueStateIds

Flag determining how server state IDs are generated.

private static final Logger
public static final String
LOGICAL_VIEW_MAP

The top level attribute name for storing the state structures within the session.

protected final Integer
numberOfLogicalViews

The number of logical views as configured by the user.

protected final Integer
numberOfViews

The number of views as configured by the user.

protected final SecureRandom
random

Used to generate unique server state IDs.

public static final String
STATEMANAGED_SERIAL_ID_KEY

Key to store the AtomicInteger used to generate unique state map keys.

Inherited from com.sun.faces.renderkit.StateHelper:
compressViewStatefieldEndfieldMiddleserialProviderstateFieldStartwebConfig

Constructor Summary

AccessConstructor and Description
public
ServerSideStateHelper()

Construct a new ServerSideStateHelper instance.

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

a unique ID for building the keys used to store views within a session
createIncrementalRequestId
(FacesContext
the FacesContext for the current request
ctx
)

private String
protected Integer

Returns:

the Integer representation of the parameter value
getIntegerConfigValue
(WebConfiguration.WebContextInitParameter
the paramter to parse
param
)

Utility method for obtaining the Integer based configuration values used to change the behavior of the ServerSideStateHelper.

public Object
getState(FacesContext ctx, String viewId)

Implements abstract com.sun.faces.renderkit.StateHelper.getState.

Inspects the incoming request parameters for the standardized state parameter name.

protected Object

Returns:

an object that can be passed to UIViewRoot.processRestoreState. If com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter#SerializeServerStateDeprecated de-serialize the state prior to returning it, otherwise return state as is.
handleRestoreState
(Object
the state as it was stored in the session
state
)

protected Object

Returns:

If com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter#SerializeServerStateDeprecated is true, serialize and return the state, otherwise, return state unchanged.
handleSaveState
(Object
the object returned from UIView.processSaveState
state
)

public boolean

Returns:

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

Implements abstract com.sun.faces.renderkit.StateHelper.isStateless.

Is stateless.
public void
writeState(FacesContext ctx, Object state, StringBuilder stateCapture)

Implements abstract com.sun.faces.renderkit.StateHelper.writeState.

Stores the provided state within the session obtained from the provided FacesContext

If stateCapture is null, the composite key used to look up the actual and logical views will be written to the client as a hidden field using the ResponseWriter from the provided FacesContext.

Inherited from com.sun.faces.renderkit.StateHelper:
createAndStoreCryptographicallyStrongTokenInSessiongetCryptographicallyStrongTokenFromSessiongetStateParamValuewriteClientWindowFieldwriteRenderKitIdField

Field Detail

generateUniqueStateIdsback to summary
protected boolean generateUniqueStateIds

Flag determining how server state IDs are generated.

LOGGERback to summary
private static final Logger LOGGER

Hides com.sun.faces.renderkit.StateHelper.LOGGER.

LOGICAL_VIEW_MAPback to summary
public static final String LOGICAL_VIEW_MAP

The top level attribute name for storing the state structures within the session.

numberOfLogicalViewsback to summary
protected final Integer numberOfLogicalViews

The number of logical views as configured by the user.

numberOfViewsback to summary
protected final Integer numberOfViews

The number of views as configured by the user.

randomback to summary
protected final SecureRandom random

Used to generate unique server state IDs.

STATEMANAGED_SERIAL_ID_KEYback to summary
public static final String STATEMANAGED_SERIAL_ID_KEY

Key to store the AtomicInteger used to generate unique state map keys.

Constructor Detail

ServerSideStateHelperback to summary
public ServerSideStateHelper()

Construct a new ServerSideStateHelper instance.

Method Detail

createIncrementalRequestIdback to summary
private String createIncrementalRequestId(FacesContext ctx)
Parameters
ctx:FacesContext

the FacesContext for the current request

Returns:String

a unique ID for building the keys used to store views within a session

createRandomIdback to summary
private String createRandomId()
getIntegerConfigValueback to summary
protected Integer getIntegerConfigValue(WebConfiguration.WebContextInitParameter param)

Utility method for obtaining the Integer based configuration values used to change the behavior of the ServerSideStateHelper.

Parameters
param:WebConfiguration.WebContextInitParameter

the paramter to parse

Returns:Integer

the Integer representation of the parameter value

getStateback to summary
public Object getState(FacesContext ctx, String viewId)

Implements abstract com.sun.faces.renderkit.StateHelper.getState.

Inspects the incoming request parameters for the standardized state parameter name. In this case, the parameter value will be the composite ID generated by ServerSideStateHelper#writeState(FacesContext, Object, StringBuilder).

The composite key will be used to find the appropriate view within the session obtained from the provided FacesContext

Annotations
@Override
handleRestoreStateback to summary
protected Object handleRestoreState(Object state)
Parameters
state:Object

the state as it was stored in the session

Returns:Object

an object that can be passed to UIViewRoot.processRestoreState. If com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter#SerializeServerStateDeprecated de-serialize the state prior to returning it, otherwise return state as is.

handleSaveStateback to summary
protected Object handleSaveState(Object state)
Parameters
state:Object

the object returned from UIView.processSaveState

Returns:Object

If com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter#SerializeServerStateDeprecated is true, serialize and return the state, otherwise, return state unchanged.

isStatelessback to summary
public boolean isStateless(FacesContext facesContext, String viewId) throws IllegalStateException

Implements abstract com.sun.faces.renderkit.StateHelper.isStateless.

Is stateless.

Parameters
facesContext:FacesContext

the Faces context.

viewId:String

the view id.

Returns:boolean

true if stateless, false otherwise.

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

Implements abstract com.sun.faces.renderkit.StateHelper.writeState.

Stores the provided state within the session obtained from the provided FacesContext

If stateCapture is null, the composite key used to look up the actual and logical views will be written to the client as a hidden field using the ResponseWriter from the provided FacesContext.

If stateCapture is not null, the composite key will be appended to the StringBuilder without any markup included or any content written to the client.

Annotations
@Override