myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1670538 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
Date Wed, 01 Apr 2015 01:32:35 GMT
Author: lu4242
Date: Wed Apr  1 01:32:35 2015
New Revision: 1670538

URL: http://svn.apache.org/r1670538
Log:
MYFACES-3949 javax.faces.ViewState autocomplete

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java?rev=1670538&r1=1670537&r2=1670538&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
(original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
Wed Apr  1 01:32:35 2015
@@ -69,13 +69,24 @@ public class HtmlResponseStateManager ex
     public static final String INIT_PARAM_HANDLE_STATE_CACHING_MECHANICS
             = "org.apache.myfaces.HANDLE_STATE_CACHING_MECHANICS";
     
+    /**
+     * Add autocomplete="off" to the view state hidden field. Enabled by default.
+     */
+    @JSFWebConfigParam(since="2.2.8, 2.1.18, 2.0.24", expectedValues="true, false", 
+           defaultValue="true", group="state")
+    public static final String INIT_PARAM_AUTOCOMPLETE_OFF_VIEW_STATE = 
+            "org.apache.myfaces.AUTOCOMPLETE_OFF_VIEW_STATE";
+    
     private Boolean _handleStateCachingMechanics;
     
     private StateCacheFactory _stateCacheFactory;
     
+    private Boolean _autoCompleteOffViewState;
+    
     public HtmlResponseStateManager()
     {
         _stateCacheFactory = new StateCacheFactoryImpl();
+        _autoCompleteOffViewState = null;
     }
     
     protected boolean isHandlingStateCachingMechanics(FacesContext facesContext)
@@ -176,6 +187,10 @@ public class HtmlResponseStateManager ex
                 responseWriter.writeAttribute(HTML.ID_ATTR, STANDARD_STATE_SAVING_PARAM,
null);
             }
             responseWriter.writeAttribute(HTML.VALUE_ATTR, serializedState, null);
+            if (this.isAutocompleteOffViewState(facesContext))
+            {
+                responseWriter.writeAttribute(HTML.AUTOCOMPLETE_ATTR, "off", null);
+            }
             responseWriter.endElement(HTML.INPUT_ELEM);
         }
     }
@@ -346,5 +361,14 @@ public class HtmlResponseStateManager ex
     {
         return _stateCacheFactory.getStateCache(facesContext);
     }
-
+    
+    private boolean isAutocompleteOffViewState(FacesContext facesContext)
+    {
+        if (_autoCompleteOffViewState == null)
+        {
+            _autoCompleteOffViewState = WebConfigParamUtils.getBooleanInitParameter(facesContext.getExternalContext(),
+                    INIT_PARAM_AUTOCOMPLETE_OFF_VIEW_STATE, true);
+        }
+        return _autoCompleteOffViewState;
+    }
 }



Mime
View raw message