Class ServerSideStateHelper
public class ServerSideStateHelper extends StateHelper
This StateHelper
provides the functionality associated with server-side state saving, though in
actuallity, it is a hybrid between client and server.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
generateUniqueStateIds
Flag determining how server state IDs are generated.static String
LOGICAL_VIEW_MAP
The top level attribute name for storing the state structures within the session.protected Integer
numberOfLogicalViews
The number of logical views as configured by the user.protected Integer
numberOfViews
The number of views as configured by the user.protected SecureRandom
random
Used to generate unique server state IDs.static String
STATEMANAGED_SERIAL_ID_KEY
Key to store theAtomicInteger
used to generate unique state map keys.Fields inherited from class com.sun.faces.renderkit.StateHelper
compressViewState, fieldEnd, fieldMiddle, serialProvider, stateFieldStart, webConfig
-
Constructor Summary
Constructors Constructor Description ServerSideStateHelper()
Construct a newServerSideStateHelper
instance. -
Method Summary
Modifier and Type Method Description protected Integer
getIntegerConfigValue(WebConfiguration.WebContextInitParameter param)
Utility method for obtaining theInteger
based configuration values used to change the behavior of theServerSideStateHelper
.Object
getState(FacesContext ctx, String viewId)
Inspects the incoming request parameters for the standardized state parameter name.protected Object
handleRestoreState(Object state)
protected Object
handleSaveState(Object state)
boolean
isStateless(FacesContext facesContext, String viewId)
Is stateless.void
writeState(FacesContext ctx, Object state, StringBuilder stateCapture)
Stores the provided state within the session obtained from the providedFacesContext
Methods inherited from class com.sun.faces.renderkit.StateHelper
createAndStoreCryptographicallyStrongTokenInSession, getCryptographicallyStrongTokenFromSession, getStateParamValue, writeClientWindowField, writeRenderKitIdField
-
Field Details
-
STATEMANAGED_SERIAL_ID_KEY
Key to store theAtomicInteger
used to generate unique state map keys. -
LOGICAL_VIEW_MAP
The top level attribute name for storing the state structures within the session. -
numberOfLogicalViews
The number of logical views as configured by the user. -
numberOfViews
The number of views as configured by the user. -
generateUniqueStateIds
protected boolean generateUniqueStateIdsFlag determining how server state IDs are generated. -
random
Used to generate unique server state IDs.
-
-
Constructor Details
-
ServerSideStateHelper
public ServerSideStateHelper()Construct a newServerSideStateHelper
instance.
-
-
Method Details
-
writeState
public void writeState(FacesContext ctx, Object state, StringBuilder stateCapture) throws IOExceptionStores the provided state within the session obtained from the provided
FacesContext
If
stateCapture
isnull
, the composite key used to look up the actual and logical views will be written to the client as a hidden field using theResponseWriter
from the providedFacesContext
.If
stateCapture
is notnull
, the composite key will be appended to theStringBuilder
without any markup included or any content written to the client.
- Specified by:
writeState
in classStateHelper
- Throws:
IOException
- See Also:
ResponseStateManager.writeState(jakarta.faces.context.FacesContext, java.lang.Object)
-
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
- Specified by:
getState
in classStateHelper
- See Also:
ResponseStateManager.getState(jakarta.faces.context.FacesContext, String)
-
getIntegerConfigValue
Utility method for obtaining the
Integer
based configuration values used to change the behavior of theServerSideStateHelper
.- Parameters:
param
- the paramter to parse- Returns:
- the Integer representation of the parameter value
-
handleSaveState
- Parameters:
state
- the object returned fromUIView.processSaveState
- Returns:
- If
WebConfiguration.BooleanWebContextInitParameter.SerializeServerStateDeprecated
istrue
, serialize and return the state, otherwise, returnstate
unchanged.
-
handleRestoreState
- Parameters:
state
- the state as it was stored in the session- Returns:
- an object that can be passed to
UIViewRoot.processRestoreState
. IfWebConfiguration.BooleanWebContextInitParameter.SerializeServerStateDeprecated
de-serialize the state prior to returning it, otherwise returnstate
as is.
-
isStateless
Is stateless.- Specified by:
isStateless
in classStateHelper
- Parameters:
facesContext
- the Faces context.viewId
- the view id.- Returns:
- true if stateless, false otherwise.
- Throws:
IllegalStateException
- when the request was not a postback.- See Also:
ResponseStateManager.isStateless(jakarta.faces.context.FacesContext, String)
-