You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2026/07/16 15:19:58 UTC
(myfaces) 01/01: MYFACES-4721: Update AUTOCOMPLETE_OFF_VIEW_STATE - 'one-time-code' as default
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch MYFACES-4721-main
in repository https://gitbox.apache.org/repos/asf/myfaces.git
commit 8432fed1a2e1edbe989a0e4bd9b026c7fd2920eb
Author: Volodymyr Siedlecki <vo...@gmail.com>
AuthorDate: Tue Apr 22 16:05:32 2025 -0400
MYFACES-4721: Update AUTOCOMPLETE_OFF_VIEW_STATE - 'one-time-code' as default
---
.../config/webparameters/MyfacesConfig.java | 22 ++++++++++++++--------
.../renderkit/html/HtmlResponseStateManager.java | 5 +++--
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/config/webparameters/MyfacesConfig.java b/impl/src/main/java/org/apache/myfaces/config/webparameters/MyfacesConfig.java
index 2ca93a918..87e5f9f8a 100755
--- a/impl/src/main/java/org/apache/myfaces/config/webparameters/MyfacesConfig.java
+++ b/impl/src/main/java/org/apache/myfaces/config/webparameters/MyfacesConfig.java
@@ -512,13 +512,13 @@ public class MyfacesConfig
private static final boolean USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT = false;
/**
- * Add autocomplete="off" to the view state hidden field. Enabled by default.
+ * Add autocomplete="..." to the view state hidden field. Set to "one-time-code" by default. (MYFACES-4721)
*/
- @JSFWebConfigParam(since="2.2.8, 2.1.18, 2.0.24", expectedValues="true, false",
- defaultValue="false", group="state")
+ @JSFWebConfigParam(since="2.2.8, 2.1.18, 2.0.24", expectedValues="true, false, one-time-code",
+ defaultValue="one-time-code", group="state")
public static final String AUTOCOMPLETE_OFF_VIEW_STATE =
"org.apache.myfaces.AUTOCOMPLETE_OFF_VIEW_STATE";
- private static final boolean AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT = false;
+ private static final String AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT = "one-time-code";
/**
* Set the max time in milliseconds set on the "Expires" header for a resource rendered by
@@ -836,7 +836,7 @@ public class MyfacesConfig
private boolean serializeStateInSession = false;
private boolean compressStateInSession = COMPRESS_STATE_IN_SESSION_DEFAULT;
private boolean useFlashScopePurgeViewsInSession = USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT;
- private boolean autocompleteOffViewState = AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT;
+ private String autocompleteOffViewState = AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT;
private long resourceMaxTimeExpires = RESOURCE_MAX_TIME_EXPIRES_DEFAULT;
private boolean lazyLoadConfigObjects = LAZY_LOAD_CONFIG_OBJECTS_DEFAULT;
private String elResolverComparator;
@@ -1162,7 +1162,7 @@ else if (refreshTransientBuildOnPSS.equalsIgnoreCase("true") ||
cfg.useFlashScopePurgeViewsInSession = getBoolean(extCtx, USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION,
USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION_DEFAULT);
- cfg.autocompleteOffViewState = getBoolean(extCtx, AUTOCOMPLETE_OFF_VIEW_STATE,
+ cfg.autocompleteOffViewState = getString(extCtx, AUTOCOMPLETE_OFF_VIEW_STATE,
AUTOCOMPLETE_OFF_VIEW_STATE_DEFAULT);
cfg.resourceMaxTimeExpires = getLong(extCtx, RESOURCE_MAX_TIME_EXPIRES,
@@ -1647,9 +1647,15 @@ public boolean isUseFlashScopePurgeViewsInSession()
return useFlashScopePurgeViewsInSession;
}
- public boolean isAutocompleteOffViewState()
+ public String getAutocompleteOffViewState()
{
- return autocompleteOffViewState;
+ if(autocompleteOffViewState.equals("false")){
+ return null;
+ }
+ if(autocompleteOffViewState.equals("true")){
+ return "off";
+ }
+ return autocompleteOffViewState; // return one-time-code
}
public long getResourceMaxTimeExpires()
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
index 837b7dda1..82fcf64c0 100755
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
@@ -138,9 +138,10 @@ private void writeViewStateField(FacesContext facesContext, ResponseWriter respo
null);
}
responseWriter.writeAttribute(HTML.VALUE_ATTR, serializedState, null);
- if (myfacesConfig.isAutocompleteOffViewState())
+ String autoCompleteValue = myfacesConfig.getAutocompleteOffViewState();
+ if (autoCompleteValue != null) // null is the "false" scenario
{
- responseWriter.writeAttribute(HTML.AUTOCOMPLETE_ATTR, "off", null);
+ responseWriter.writeAttribute(HTML.AUTOCOMPLETE_ATTR, autoCompleteValue, null);
}
responseWriter.endElement(HTML.INPUT_ELEM);
}