A ResonseStateManager
implementation for the default HTML render kit.
-
Field Summary
Fields inherited from class jakarta.faces.render.ResponseStateManager
CLIENT_WINDOW_PARAM, CLIENT_WINDOW_URL_PARAM, NON_POSTBACK_VIEW_TOKEN_PARAM, RENDER_KIT_ID_PARAM, VIEW_STATE_PARAM
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCompliant implementations must return a cryptographically strong token for use to protect views in this application.getState
(FacesContext context, String viewId) The implementation must inspect the current request and return an Object representing the tree structure and component state passed in to a previous invocation ofResponseStateManager.writeState(jakarta.faces.context.FacesContext,java.lang.Object)
.getViewState
(FacesContext context, Object state) Return the specified state as aString
without any markup related to the rendering technology supported by this ResponseStateManager.boolean
isPostback
(FacesContext context) Return true if the current request is a postback.boolean
isStateless
(FacesContext facesContext, String viewId) If the preceding call toResponseStateManager.writeState(jakarta.faces.context.FacesContext, java.lang.Object)
was stateless, returntrue
.void
writeState
(FacesContext context, Object state) Take the argumentstate
and write it into the output using the currentResponseWriter
, which must be correctly positioned already.
-
Constructor Details
-
ResponseStateManagerImpl
public ResponseStateManagerImpl()
-
-
Method Details
-
isPostback
Description copied from class:ResponseStateManager
Return true if the current request is a postback. This method is leveraged from the Restore View Phase to determine if
ViewHandler.restoreView(jakarta.faces.context.FacesContext, java.lang.String)
orViewHandler.createView(jakarta.faces.context.FacesContext, java.lang.String)
should be called. The default implementation must returntrue
if thisResponseStateManager
instance wrote out state on a previous request to which this request is a postback,false
otherwise.The implementation of this method for the Standard HTML RenderKit must consult the
ExternalContext
'srequestParameterMap
and returntrue
if and only if there is a key equal to the value of the symbolic constantResponseStateManager.VIEW_STATE_PARAM
.For backwards compatibility with implementations of
ResponseStateManager
prior to Jakarta Faces 1.2, a default implementation is provided that consults theExternalContext
'srequestParameterMap
and returntrue
if its size is greater than 0.- Overrides:
isPostback
in classResponseStateManager
- Parameters:
context
- theFacesContext
for the current request.- Returns:
- the value as specified above
- See Also:
-
getCryptographicallyStrongTokenFromSession
Description copied from class:ResponseStateManager
Compliant implementations must return a cryptographically strong token for use to protect views in this application. For backwards compatibility with earlier revisions, a default implementation is provided that simply returns
null
.- Overrides:
getCryptographicallyStrongTokenFromSession
in classResponseStateManager
- Parameters:
context
- theFacesContext
for the current request- Returns:
- a cryptographically strong value
-
getState
Description copied from class:ResponseStateManager
The implementation must inspect the current request and return an Object representing the tree structure and component state passed in to a previous invocation of
ResponseStateManager.writeState(jakarta.faces.context.FacesContext,java.lang.Object)
.If the state saving method for this application is
StateManager.STATE_SAVING_METHOD_CLIENT
,writeState()
will have encrypted the state in a tamper evident manner. If the state fails to decrypt, or decrypts but indicates evidence of tampering, aProtectedViewException
must be thrown.- Overrides:
getState
in classResponseStateManager
- Parameters:
context
- TheFacesContext
instance for the current requestviewId
- View identifier of the view to be restored- Returns:
- the tree structure and component state Object passed in to
writeState
. If this is an initial request, this method returnsnull
. - See Also:
-
writeState
Description copied from class:ResponseStateManager
Take the argument
state
and write it into the output using the currentResponseWriter
, which must be correctly positioned already.Call
FacesContext.getViewRoot()
. IfStateHolder.isTransient()
returnstrue
, take implementation specific action so that the following call toResponseStateManager.isStateless(jakarta.faces.context.FacesContext, java.lang.String)
returnstrue
and return. Otherwise, proceed as follows.If the state is to be written out to hidden fields, the implementation must take care to make all necessary character replacements to make the Strings suitable for inclusion as an HTTP request paramater.
If the state saving method for this application is
StateManager.STATE_SAVING_METHOD_CLIENT
, the implementation must encrypt the state to be saved to the client in a tamper evident manner.If the state saving method for this application is
StateManager.STATE_SAVING_METHOD_SERVER
, and the current request is anAjax
requestPartialViewContext.isAjaxRequest()
returnstrue
), use the current view state identifier if it is available (do not generate a new identifier).Write out the render kit identifier associated with this
ResponseStateManager
implementation with the name as the value of theString
constantResponseStateManager.RENDER_KIT_ID_PARAM
. The render kit identifier must not be written if:- it is the default render kit identifier as returned by
Application.getDefaultRenderKitId()
or - the render kit identfier is the value of
jakarta.faces.render.RenderKitFactory.HTML_BASIC_RENDER_KIT
andApplication.getDefaultRenderKitId()
returnsnull
.
The
ClientWindow
must be written using these steps. CallExternalContext.getClientWindow()
. If the result isnull
, take no further action regarding theClientWindow
. If the result is non-null
, write a hidden field whose name isResponseStateManager.CLIENT_WINDOW_PARAM
and whose id is<VIEW_ROOT_CONTAINER_CLIENT_ID><SEP>jakarta.faces.ClientWindow<SEP><UNIQUE_PER_VIEW_NUMBER>
where <SEP> is the currently configuredUINamingContainer.getSeparatorChar()
. <VIEW_ROOT_CONTAINER_CLIENT_ID> is the return fromUIViewRoot.getContainerClientId()
on the view from whence this state originated. <UNIQUE_PER_VIEW_NUMBER> is a number that must be unique within this view, but must not be included in the view state. The value of the field is implementation dependent but must uniquely identify this window within the user's session.- Overrides:
writeState
in classResponseStateManager
- Parameters:
context
- TheFacesContext
instance for the current requeststate
- The serialized state information previously saved- Throws:
IOException
- if the state argument is not an array of length 2.- See Also:
- it is the default render kit identifier as returned by
-
getViewState
Description copied from class:ResponseStateManager
Return the specified state as a
String
without any markup related to the rendering technology supported by this ResponseStateManager.- Overrides:
getViewState
in classResponseStateManager
- Parameters:
context
- theFacesContext
for the current requeststate
- the state from which the String version will be generated from- Returns:
- the view state for this request without any markup specifics
- See Also:
-
isStateless
Description copied from class:ResponseStateManager
If the preceding call to
ResponseStateManager.writeState(jakarta.faces.context.FacesContext, java.lang.Object)
was stateless, returntrue
. If the preceding call towriteState()
was stateful, returnfalse
. Otherwise throwIllegalStateException
.To preserve backward compatibility with custom implementations that may have extended from an earlier version of this class, an implementation is provided that returns
false
. A compliant implementation must override this method to take the specified action.- Overrides:
isStateless
in classResponseStateManager
- Parameters:
facesContext
- the Faces context.viewId
- the view id.- Returns:
- true if "stateless" was found, false otherwise.
- Throws:
IllegalStateException
- when the request is not a postback.
-