Top Description Fields Constructors Methods
jakarta.faces.application

public abstract Class StateManager

extends Object
Class Inheritance
Known Direct Subclasses
jakarta.faces.application.StateManagerWrapper, com.sun.faces.application.StateManagerImpl
Static Imports
java.lang.Boolean.TRUE

StateManager directs the process of saving and restoring the view between requests. An implementation of this class must be thread-safe. The StateManager instance for an application is retrieved from the Application instance, and thus cannot know any details of the markup language created by the RenderKit being used to render a view. The StateManager utilizes a helper object (ResponseStateManager), that is provided by the RenderKit implementation and is therefore aware of the markup language details.

Field Summary

Modifier and TypeField and Description
public static final String
FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME

Deprecated for removal since 4.1. Full state saving will be removed in favor of partial state saving in order to keep the spec simple. Therefore specifying full state saving view IDs via this context parameter will not anymore be an option.

The runtime must interpret the value of this parameter as a comma separated list of view IDs, each of which must have their state saved using the state saving mechanism specified in Jakarta Faces 1.2.

public static final String
IS_BUILDING_INITIAL_STATE

Marker within the FacesContext attributes map to indicate we are marking initial state, so the markInitialState() method of iterating components such as jakarta.faces.component.UIData could recognize this fact and save the initial state of descendents.

public static final String
IS_SAVING_STATE

Marker within the FacesContext attributes map to indicate we are saving state.

public static final String
PARTIAL_STATE_SAVING_PARAM_NAME

Deprecated for removal since 4.1. Full state saving will be removed in favor of partial state saving in order to keep the spec simple. Therefore disabling partial state saving via this context parameter will not anymore be an option.

The ServletContext init parameter consulted by the runtime to determine if the partial state saving mechanism should be used.

private Boolean
public static final String
SERIALIZE_SERVER_STATE_PARAM_NAME

If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, and the jakarta.faces.STATE_SAVING_METHOD is set to "server" (as indicated below), the server state must be guaranteed to be Serializable such that the aggregate state implements java.io.Serializable.

public static final String
STATE_SAVING_METHOD_CLIENT

Constant value for the initialization parameter named by the STATE_SAVING_METHOD_PARAM_NAME that indicates state saving should take place on the client.

public static final String
STATE_SAVING_METHOD_PARAM_NAME

The ServletContext init parameter consulted by the StateManager to tell where the state should be saved.

public static final String
STATE_SAVING_METHOD_SERVER

Constant value for the initialization parameter named by the STATE_SAVING_METHOD_PARAM_NAME that indicates state saving should take place on the server.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the view state.
getViewState
(FacesContext
FacesContext for the current request
context
)

Convenience method to return the view state as a String with no RenderKit specific markup.

public boolean

Returns:

true if and only if the value of the ServletContext init parameter named by the value of the constant STATE_SAVING_METHOD_PARAM_NAME is equal (ignoring case) to the value of the constant STATE_SAVING_METHOD_CLIENT. false otherwise.
isSavingStateInClient
(FacesContext
the Faces context.
context
)

Method to determine if the state is saved on the client.

public void
writeState(FacesContext
FacesContext for the current request
context
,
Object
the state to be written
state
)

Save the state represented in the specified state Object instance, in an implementation dependent manner.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FULL_STATE_SAVING_VIEW_IDS_PARAM_NAMEback to summary
public static final String FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME

Deprecated

for removal since 4.1.

Full state saving will be removed in favor of partial state saving in order to keep the spec simple. Therefore specifying full state saving view IDs via this context parameter will not anymore be an option.

The runtime must interpret the value of this parameter as a comma separated list of view IDs, each of which must have their state saved using the state saving mechanism specified in Jakarta Faces 1.2.

Annotations
@Deprecated
forRemoval:true
since:4.1
IS_BUILDING_INITIAL_STATEback to summary
public static final String IS_BUILDING_INITIAL_STATE

Marker within the FacesContext attributes map to indicate we are marking initial state, so the markInitialState() method of iterating components such as jakarta.faces.component.UIData could recognize this fact and save the initial state of descendents.

Since
2.1
IS_SAVING_STATEback to summary
public static final String IS_SAVING_STATE

Marker within the FacesContext attributes map to indicate we are saving state. The implementation must set this marker into the map before starting the state saving traversal and the marker must be cleared, in a finally block, after the traversal is complete.

PARTIAL_STATE_SAVING_PARAM_NAMEback to summary
public static final String PARTIAL_STATE_SAVING_PARAM_NAME

Deprecated

for removal since 4.1.

Full state saving will be removed in favor of partial state saving in order to keep the spec simple. Therefore disabling partial state saving via this context parameter will not anymore be an option.

The ServletContext init parameter consulted by the runtime to determine if the partial state saving mechanism should be used.

If undefined, the runtime must determine the version level of the application.

  • For applications versioned at 1.2 and under, the runtime must not use the partial state saving mechanism.

  • For applications versioned at 2.0 and above, the runtime must use the partial state saving mechanism.

If this parameter is defined, and the application is versioned at 1.2 and under, the runtime must not use the partial state saving mechanism. Otherwise, If this param is defined, and calling toLowerCase().equals("true") on a String representation of its value returns true, the runtime must use partial state mechanism. Otherwise the partial state saving mechanism must not be used.

Annotations
@Deprecated
forRemoval:true
since:4.1
Since
2.0
savingStateInClientback to summary
private Boolean savingStateInClient
SERIALIZE_SERVER_STATE_PARAM_NAMEback to summary
public static final String SERIALIZE_SERVER_STATE_PARAM_NAME

If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, and the jakarta.faces.STATE_SAVING_METHOD is set to "server" (as indicated below), the server state must be guaranteed to be Serializable such that the aggregate state implements java.io.Serializable. The intent of this parameter is to ensure that the act of writing out the state to an ObjectOutputStream would not throw a NotSerializableException, but the runtime is not required verify this before saving the state.

Since
2.2
STATE_SAVING_METHOD_CLIENTback to summary
public static final String STATE_SAVING_METHOD_CLIENT

Constant value for the initialization parameter named by the STATE_SAVING_METHOD_PARAM_NAME that indicates state saving should take place on the client.

STATE_SAVING_METHOD_PARAM_NAMEback to summary
public static final String STATE_SAVING_METHOD_PARAM_NAME

The ServletContext init parameter consulted by the StateManager to tell where the state should be saved. Valid values are given as the values of the constants: STATE_SAVING_METHOD_CLIENT or STATE_SAVING_METHOD_SERVER.

If this parameter is not specified, the default value is the value of the constant STATE_SAVING_METHOD_CLIENT.

STATE_SAVING_METHOD_SERVERback to summary
public static final String STATE_SAVING_METHOD_SERVER

Constant value for the initialization parameter named by the STATE_SAVING_METHOD_PARAM_NAME that indicates state saving should take place on the server.

Constructor Detail

StateManagerback to summary
public StateManager()

Method Detail

getViewStateback to summary
public String getViewState(FacesContext context)

Convenience method to return the view state as a String with no RenderKit specific markup. This default implementation of this method will call StateManagementStrategy#saveView(FacesContext) and passing the result to and returning the resulting value from ResponseStateManager#getViewState(jakarta.faces.context.FacesContext, Object).

Parameters
context:FacesContext

FacesContext for the current request

Returns:String

the view state.

Since
2.0
isSavingStateInClientback to summary
public boolean isSavingStateInClient(FacesContext context)

Method to determine if the state is saved on the client.

Parameters
context:FacesContext

the Faces context.

Returns:boolean

true if and only if the value of the ServletContext init parameter named by the value of the constant STATE_SAVING_METHOD_PARAM_NAME is equal (ignoring case) to the value of the constant STATE_SAVING_METHOD_CLIENT. false otherwise.

Exceptions
NullPointerException:
if context is null.
writeStateback to summary
public void writeState(FacesContext context, Object state) throws IOException

Save the state represented in the specified state Object instance, in an implementation dependent manner.

This method will typically simply delegate the actual writing to the writeState() method of the ResponseStateManager instance provided by the RenderKit being used to render this view. This method assumes that the caller has positioned the ResponseWriter at the correct position for the saved state to be written.

Parameters
context:FacesContext

FacesContext for the current request

state:Object

the state to be written

Exceptions
IOException:
when an I/O error occurs.
Since
1.2