Class ServerSideStateHelper
- java.lang.Object
-
- com.sun.faces.renderkit.StateHelper
-
- com.sun.faces.renderkit.ServerSideStateHelper
-
public class ServerSideStateHelper extends StateHelper
ThisStateHelperprovides the functionality associated with server-side state saving, though in actuality, it is a hybrid between client and server.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleangenerateUniqueStateIdsFlag determining how server state IDs are generated.static StringLOGICAL_VIEW_MAPThe top level attribute name for storing the state structures within the session.protected IntegernumberOfLogicalViewsThe number of logical views as configured by the user.protected IntegernumberOfViewsThe number of views as configured by the user.protected SecureRandomrandomUsed to generate unique server state IDs.static StringSTATEMANAGED_SERIAL_ID_KEYKey to store theAtomicIntegerused 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 newServerSideStateHelperinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IntegergetIntegerConfigValue(WebConfiguration.WebContextInitParameter param)Utility method for obtaining theIntegerbased configuration values used to change the behavior of theServerSideStateHelper.ObjectgetState(FacesContext ctx, String viewId)Inspects the incoming request parameters for the standardized state parameter name.protected ObjecthandleRestoreState(Object state)protected ObjecthandleSaveState(Object state)booleanisStateless(FacesContext facesContext, String viewId)Is stateless.voidwriteState(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 Detail
-
STATEMANAGED_SERIAL_ID_KEY
public static final String STATEMANAGED_SERIAL_ID_KEY
Key to store theAtomicIntegerused to generate unique state map keys.
-
LOGICAL_VIEW_MAP
public static final String LOGICAL_VIEW_MAP
The top level attribute name for storing the state structures within the session.
-
numberOfLogicalViews
protected final Integer numberOfLogicalViews
The number of logical views as configured by the user.
-
numberOfViews
protected final Integer numberOfViews
The number of views as configured by the user.
-
generateUniqueStateIds
protected boolean generateUniqueStateIds
Flag determining how server state IDs are generated.
-
random
protected final SecureRandom random
Used to generate unique server state IDs.
-
-
Method Detail
-
writeState
public void writeState(FacesContext ctx, Object state, StringBuilder stateCapture) throws IOException
Stores the provided state within the session obtained from the provided
FacesContextIf
stateCaptureisnull, the composite key used to look up the actual and logical views will be written to the client as a hidden field using theResponseWriterfrom the providedFacesContext.If
stateCaptureis notnull, the composite key will be appended to theStringBuilderwithout any markup included or any content written to the client.- Specified by:
writeStatein classStateHelper- Throws:
IOException- See Also:
ResponseStateManager.writeState(jakarta.faces.context.FacesContext, java.lang.Object)
-
getState
public Object getState(FacesContext ctx, String viewId)
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:
getStatein classStateHelper- See Also:
ResponseStateManager.getState(jakarta.faces.context.FacesContext, String)
-
getIntegerConfigValue
protected Integer getIntegerConfigValue(WebConfiguration.WebContextInitParameter param)
Utility method for obtaining the
Integerbased configuration values used to change the behavior of theServerSideStateHelper.- Parameters:
param- the paramter to parse- Returns:
- the Integer representation of the parameter value
-
handleSaveState
protected Object handleSaveState(Object state)
- Parameters:
state- the object returned fromUIView.processSaveState- Returns:
- If option
SerializeServerStateistrue, serialize and return the state, otherwise, returnstateunchanged.
-
handleRestoreState
protected Object handleRestoreState(Object state)
- Parameters:
state- the state as it was stored in the session- Returns:
- an object that can be passed to
UIViewRoot.processRestoreState. If optionSerializeServerStatetrue de-serialize the state prior to returning it, otherwise returnstateas is.
-
isStateless
public boolean isStateless(FacesContext facesContext, String viewId) throws IllegalStateException
Is stateless.- Specified by:
isStatelessin 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)
-
-