com.sun.faces.renderkit
public class ClientSideStateHelper extends StateHelper
This StateHelper
provides the functionality associated with client-side state saving.
Modifier and Type | Class and Description |
---|---|
protected static class |
ClientSideStateHelper.StringBuilderWriter
A simple
Writer implementation to encapsulate a
StringBuilder instance. |
Modifier and Type | Field and Description |
---|---|
private int |
csBuffSize
Client state is generally large, so this allows some tuning to control
the buffer that's used to write the client state.
|
private boolean |
debugSerializedState |
private ByteArrayGuard |
guard
Enabled encryption of view state.
|
private static java.util.logging.Logger |
LOGGER |
protected boolean |
namespaceParameters
Flag determining whether or not javax.faces.ViewState should be namespaced.
|
private long |
stateTimeout
If
stateTimeoutEnabled is true this value will
represent the time in seconds that a particular client view state is
valid for. |
private boolean |
stateTimeoutEnabled
Flag indicating whether or not client view state will be manipulated
for and checked against a configured timeout value.
|
compressViewState, serialProvider, STATE_FIELD_AUTOCOMPLETE_END, STATE_FIELD_END, STATE_FIELD_START, STATE_FIELD_START_NO_ID, stateFieldEnd, stateFieldStart, webConfig
Constructor and Description |
---|
ClientSideStateHelper()
Construct a new
ClientSideStateHelper instance. |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
doGetState(java.lang.String stateString)
Rebuilds the view state from the Base64 included String included
with the request.
|
protected void |
doWriteState(javax.faces.context.FacesContext facesContext,
java.lang.Object state,
java.io.Writer writer)
Serializes and Base64 encodes the provided
state to the
provided writer / |
java.lang.Object |
getState(javax.faces.context.FacesContext ctx,
java.lang.String viewId)
Inspects the incoming request parameters for the standardized state
parameter name.
|
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. |
protected void |
init()
Initialze the various configuration options for client-side
sate saving.
|
void |
writeState(javax.faces.context.FacesContext ctx,
java.lang.Object state,
java.lang.StringBuilder stateCapture)
Writes the view state as a String generated by Base64 encoding the
Java Serialziation representation of the provided
state |
getStateParamValue, writeRenderKitIdField
private static final java.util.logging.Logger LOGGER
private ByteArrayGuard guard
Enabled encryption of view state. Encryption is disabled by default.
com.sun.faces.config.WebConfiguration.WebEnvironmentEntry#ClientStateSavingPassword}
private boolean stateTimeoutEnabled
Flag indicating whether or not client view state will be manipulated for and checked against a configured timeout value.
This flag is configured via the WebContextInitParameter.ClientStateTimeout
configuration option of WebConfiguration
and is disabled by
default.
com.sun.faces.config.WebConfiguration.WebContextInitParameter#ClientStateTimeout}
private long stateTimeout
If stateTimeoutEnabled
is true
this value will
represent the time in seconds that a particular client view state is
valid for.
com.sun.faces.config.WebConfiguration.WebContextInitParameter#ClientStateTimeout}
private int csBuffSize
Client state is generally large, so this allows some tuning to control the buffer that's used to write the client state.
The value specified must be divisable by two as the buffer is split between character and bytes (due to how client state is written). By default, the buffer size is 8192 (per request).
com.sun.faces.config.WebConfiguration.WebContextInitParameter#ClientStateWriteBufferSize}
private boolean debugSerializedState
protected boolean namespaceParameters
public ClientSideStateHelper()
ClientSideStateHelper
instance.public void writeState(javax.faces.context.FacesContext ctx, java.lang.Object state, java.lang.StringBuilder stateCapture) throws java.io.IOException
Writes the view state as a String generated by Base64 encoding the
Java Serialziation representation of the provided state
If stateCapture
is null
, the Base64 encoded
state will be written to the client as a hidden field using the ResponseWriter
from the provided FacesContext
.
If stateCapture
is not null
, the Base64 encoded
state will be appended to the provided StringBuilder
without any markup
included or any content written to the client.
writeState
in class StateHelper
java.io.IOException
StateHelper.writeState(javax.faces.context.FacesContext, java.lang.Object, java.lang.StringBuilder)
public java.lang.Object getState(javax.faces.context.FacesContext ctx, java.lang.String viewId) throws java.io.IOException
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.
getState
in class StateHelper
java.io.IOException
StateHelper.getState(javax.faces.context.FacesContext, java.lang.String)
protected java.lang.Object doGetState(java.lang.String stateString)
stateString
- the Base64 encoded view statestateString
protected void doWriteState(javax.faces.context.FacesContext facesContext, java.lang.Object state, java.io.Writer writer) throws java.io.IOException
state
to the
provided writer
/facesContext
- the Faces context.state
- view statewriter
- the Writer
to write the content tojava.io.IOException
- if an error occurs writing the state to the clientprotected 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, return true
. If the client state hasn't expired,
or the init parameter wasn't set, return false
.
stateTime
- the time in milliseconds that the state was written
to the clientfalse
if the client state hasn't timed out, otherwise
return true
protected void init()
Initialze the various configuration options for client-side sate saving.
Copyright © 2002-2010 Oracle America, Inc. All Rights Reserved.