This StateHelper
provides the functionality associated with client-side state saving.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
A simpleWriter
implementation to encapsulate aStringBuilder
instance. -
Field Summary
Fields inherited from class com.sun.faces.renderkit.StateHelper
compressViewState, fieldEnd, fieldMiddle, serialProvider, stateFieldStart, webConfig
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Object
doGetState
(FacesContext ctx, String stateString) Rebuilds the view state from the Base64 included String included with the request.protected void
doWriteState
(FacesContext facesContext, Object state, Writer writer) Serializes and Base64 encodes the providedstate
to the providedwriter
/getState
(FacesContext ctx, String viewId) Inspects the incoming request parameters for the standardized state parameter name.protected boolean
hasStateExpired
(long stateTime) If theWebConfiguration.WebContextInitParameter.ClientStateTimeout
init parameter is set, calculate the elapsed time between the time the client state was written and the time this method was invoked during restore.protected void
init()
Initialze the various configuration options for client-side sate saving.boolean
isStateless
(FacesContext facesContext, String viewId) Is stateless.void
writeState
(FacesContext ctx, Object state, StringBuilder stateCapture) Writes the view state as a String generated by Base64 encoding the Java Serialziation representation of the providedstate
Methods inherited from class com.sun.faces.renderkit.StateHelper
createAndStoreCryptographicallyStrongTokenInSession, getCryptographicallyStrongTokenFromSession, getStateParamValue, writeClientWindowField, writeRenderKitIdField
-
Field Details
-
STATELESS
- See Also:
-
-
Constructor Details
-
ClientSideStateHelper
public ClientSideStateHelper()Construct a newClientSideStateHelper
instance.
-
-
Method Details
-
writeState
public void writeState(FacesContext ctx, Object state, StringBuilder stateCapture) throws IOException Writes the view state as a String generated by Base64 encoding the Java Serialziation representation of the provided
state
If
stateCapture
isnull
, the Base64 encoded state will be written to the client as a hidden field using theResponseWriter
from the providedFacesContext
.If
stateCapture
is notnull
, the Base64 encoded state will be appended to the providedStringBuilder
without any markup included or any content written to the client.- Specified by:
writeState
in classStateHelper
- Throws:
IOException
- See Also:
-
getState
Inspects the incoming request parameters for the standardized state parameter name. In this case, the parameter value will be a Base64 encoded string previously encoded by ServerSideStateHelper#writeState(FacesContext, Object, StringBuilder).
The string will be Base64-decoded and the state reconstructed using standard Java serialization.
- Specified by:
getState
in classStateHelper
- Throws:
IOException
- See Also:
-
doGetState
Rebuilds the view state from the Base64 included String included with the request.- Parameters:
stateString
- the Base64 encoded view state- Returns:
- the view state reconstructed from
stateString
-
doWriteState
protected void doWriteState(FacesContext facesContext, Object state, Writer writer) throws IOException Serializes and Base64 encodes the providedstate
to the providedwriter
/- Parameters:
facesContext
- the Faces context.state
- view statewriter
- theWriter
to write the content to- Throws:
IOException
- if an error occurs writing the state to the client
-
hasStateExpired
protected boolean hasStateExpired(long stateTime) If the
WebConfiguration.WebContextInitParameter.ClientStateTimeout
init parameter is set, calculate the elapsed time between the time the client state was written and the time this method was invoked during restore. If the client state has expired, returntrue
. If the client state hasn't expired, or the init parameter wasn't set, returnfalse
.- Parameters:
stateTime
- the time in milliseconds that the state was written to the client- Returns:
false
if the client state hasn't timed out, otherwise returntrue
-
init
protected void init()Initialze the various configuration options for client-side sate saving.
-
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:
-