diff --git a/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java b/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java index caaa2cf468..c4154ed06a 100644 --- a/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java +++ b/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java @@ -21,7 +21,6 @@ import static com.sun.faces.RIConstants.FLOW_DEFINITION_ID_SUFFIX; import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsBufferSize; import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsViewMappings; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.StateSavingMethod; import static com.sun.faces.context.StateContext.getStateContext; import static com.sun.faces.facelets.tag.ui.UIDebug.debugRequest; import static com.sun.faces.renderkit.RenderKitUtils.getResponseStateManager; @@ -42,7 +41,6 @@ import static jakarta.faces.application.ProjectStage.Development; import static jakarta.faces.application.Resource.COMPONENT_RESOURCE_KEY; import static jakarta.faces.application.StateManager.IS_BUILDING_INITIAL_STATE; -import static jakarta.faces.application.StateManager.STATE_SAVING_METHOD_SERVER; import static jakarta.faces.application.ViewHandler.CHARACTER_ENCODING_KEY; import static jakarta.faces.application.ViewHandler.DEFAULT_FACELETS_SUFFIX; import static jakarta.faces.application.ViewVisitOption.RETURN_AS_MINIMAL_IMPLICIT_OUTCOME; @@ -80,6 +78,7 @@ import com.sun.faces.application.ApplicationAssociate; import com.sun.faces.config.WebConfiguration; +import com.sun.faces.config.WebConfiguration.WebContextInitParameter; import com.sun.faces.context.StateContext; import com.sun.faces.facelets.compiler.FaceletDoctype; import com.sun.faces.facelets.el.ContextualCompositeMethodExpression; @@ -106,6 +105,7 @@ import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; import jakarta.faces.application.Resource; +import jakarta.faces.application.StateManager.StateSavingMethod; import jakarta.faces.application.ViewHandler; import jakarta.faces.application.ViewVisitOption; import jakarta.faces.component.ActionSource; @@ -1854,7 +1854,7 @@ private void reapplyDynamicRemove(FacesContext context, ComponentStruct struct) * @return true if we are, false otherwise. */ private boolean isServerStateSaving() { - if (STATE_SAVING_METHOD_SERVER.equals(webConfig.getOptionValue(StateSavingMethod))) { + if (StateSavingMethod.SERVER.name().equalsIgnoreCase(webConfig.getOptionValue(WebContextInitParameter.StateSavingMethod))) { return true; } diff --git a/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java b/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java index 3f09244f68..8125c8de7d 100644 --- a/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java +++ b/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java @@ -16,17 +16,17 @@ package com.sun.faces.renderkit; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.StateSavingMethod; import static com.sun.faces.util.RequestStateManager.FACES_VIEW_STATE; -import static jakarta.faces.application.StateManager.STATE_SAVING_METHOD_CLIENT; import java.io.IOException; import com.sun.faces.config.WebConfiguration; +import com.sun.faces.config.WebConfiguration.WebContextInitParameter; import com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter; import com.sun.faces.util.RequestStateManager; import jakarta.faces.FacesException; +import jakarta.faces.application.StateManager.StateSavingMethod; import jakarta.faces.context.FacesContext; import jakarta.faces.render.ResponseStateManager; @@ -40,8 +40,8 @@ public class ResponseStateManagerImpl extends ResponseStateManager { public ResponseStateManagerImpl() { WebConfiguration webConfig = WebConfiguration.getInstance(); - String stateMode = webConfig.getOptionValue(StateSavingMethod); - helper = STATE_SAVING_METHOD_CLIENT.equalsIgnoreCase(stateMode) ? new ClientSideStateHelper() : new ServerSideStateHelper(); + String stateMode = webConfig.getOptionValue(WebContextInitParameter.StateSavingMethod); + helper = StateSavingMethod.CLIENT.name().equalsIgnoreCase(stateMode) ? new ClientSideStateHelper() : new ServerSideStateHelper(); } // --------------------------------------- Methods from ResponseStateManager diff --git a/impl/src/main/java/jakarta/faces/application/StateManager.java b/impl/src/main/java/jakarta/faces/application/StateManager.java index 5b0c9de323..5708922c84 100644 --- a/impl/src/main/java/jakarta/faces/application/StateManager.java +++ b/impl/src/main/java/jakarta/faces/application/StateManager.java @@ -47,13 +47,12 @@ public abstract class StateManager { /** *
* 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: {@link #STATE_SAVING_METHOD_CLIENT} or
- * {@link #STATE_SAVING_METHOD_SERVER}.
+ * should be saved. Valid values are given as the values of the enum constants
+ * {@link StateSavingMethod}, case insensitive.
*
- * If this parameter is not specified, the default value is the value of the constant - * {@link #STATE_SAVING_METHOD_CLIENT}. + * If this parameter is not specified, the default value is {@link StateSavingMethod#CLIENT} *
*/ public static final String STATE_SAVING_METHOD_PARAM_NAME = "jakarta.faces.STATE_SAVING_METHOD"; @@ -146,7 +145,10 @@ public abstract class StateManager { * Constant value for the initialization parameter named by theSTATE_SAVING_METHOD_PARAM_NAME
that
* indicates state saving should take place on the client.
*
+ *
+ * @deprecated Use {@link StateSavingMethod#CLIENT} instead.
*/
+ @Deprecated(since = "5.0", forRemoval = true)
public static final String STATE_SAVING_METHOD_CLIENT = "client";
/**
@@ -154,9 +156,36 @@ public abstract class StateManager {
* Constant value for the initialization parameter named by the STATE_SAVING_METHOD_PARAM_NAME
that
* indicates state saving should take place on the server.
*
+ *
+ * @deprecated Use {@link StateSavingMethod#SERVER} instead.
*/
+ @Deprecated(since = "5.0", forRemoval = true)
public static final String STATE_SAVING_METHOD_SERVER = "server";
+ /**
+ * + * Allowed values for the initialization parameter named by the {@value StateManager#STATE_SAVING_METHOD_PARAM_NAME}. + *
+ * + * @since 5.0 + */ + public enum StateSavingMethod { + + /** + *+ * Indicates that state saving should take place on the client. + *
+ */ + CLIENT, + + /** + *+ * Indicates that state saving should take place on the server. + *
+ */ + SERVER; + } + private Boolean savingStateInClient; @@ -196,7 +225,7 @@ public void writeState(FacesContext context, Object state) throws IOException { * @param context the Faces context. * @returntrue
if and only if the value of the ServletContext
init parameter named by the
* value of the constant {@link #STATE_SAVING_METHOD_PARAM_NAME} is equal (ignoring
- * case) to the value of the constant {@link #STATE_SAVING_METHOD_CLIENT}. false
otherwise.
+ * case) to the value of the constant {@link StateSavingMethod#CLIENT}. false
otherwise.
*
* @throws NullPointerException if context
is null
.
*/
@@ -207,7 +236,7 @@ public boolean isSavingStateInClient(FacesContext context) {
savingStateInClient = false;
String saveStateParam = context.getExternalContext().getInitParameter(STATE_SAVING_METHOD_PARAM_NAME);
- if (saveStateParam != null && saveStateParam.equalsIgnoreCase(STATE_SAVING_METHOD_CLIENT)) {
+ if (StateSavingMethod.CLIENT.name().equalsIgnoreCase(saveStateParam)) {
savingStateInClient = true;
}
diff --git a/impl/src/main/java/jakarta/faces/render/ResponseStateManager.java b/impl/src/main/java/jakarta/faces/render/ResponseStateManager.java
index b44f4638ac..7205f9e9f3 100644
--- a/impl/src/main/java/jakarta/faces/render/ResponseStateManager.java
+++ b/impl/src/main/java/jakarta/faces/render/ResponseStateManager.java
@@ -18,6 +18,7 @@
import java.io.IOException;
+import jakarta.faces.application.StateManager.StateSavingMethod;
import jakarta.faces.context.FacesContext;
import jakarta.faces.context.ResponseWriter;
@@ -117,15 +118,15 @@ public abstract class ResponseStateManager {
*
* * If the state saving method for this application is - * {@link jakarta.faces.application.StateManager#STATE_SAVING_METHOD_CLIENT}, the implementation + * {@link StateSavingMethod#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
- * {@link jakarta.faces.application.StateManager#STATE_SAVING_METHOD_SERVER}, and the current request is an
- * Ajax
request {@link jakarta.faces.context.PartialViewContext#isAjaxRequest} returns true
),
+ * {@link StateSavingMethod#SERVER}, and the current request is an
+ * Ajax
request ({@link jakarta.faces.context.PartialViewContext#isAjaxRequest} returns true
),
* use the current view state identifier if it is available (do not generate a new identifier).
*
* If the state saving method for this application is
- * {@link jakarta.faces.application.StateManager#STATE_SAVING_METHOD_CLIENT}, writeState()
will have
+ * {@link StateSavingMethod#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, a {@link jakarta.faces.application.ProtectedViewException} must be thrown.
*