myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1298643 - /myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java
Date Thu, 08 Mar 2012 23:00:07 GMT
Author: lu4242
Date: Thu Mar  8 23:00:07 2012
New Revision: 1298643

URL: http://svn.apache.org/viewvc?rev=1298643&view=rev
Log:
MYFACES-3495 [perf] do not store default validationGroups for bean validation

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java?rev=1298643&r1=1298642&r2=1298643&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java Thu Mar
 8 23:00:07 2012
@@ -119,6 +119,8 @@ public class BeanValidator implements Va
     
     private static final Class<?>[] DEFAULT_VALIDATION_GROUPS_ARRAY = new Class<?>[]
{ Default.class };
 
+    private static final String DEFAULT_VALIDATION_GROUP_NAME = "javax.validation.groups.Default";
+
     private String validationGroups;
 
     private Class<?>[] validationGroupsArray;
@@ -381,14 +383,38 @@ public class BeanValidator implements Va
     /** {@inheritDoc} */
     public Object saveState(final FacesContext context)
     {
-        return this.validationGroups;
+        if (!initialStateMarked())
+        {
+           //Full state saving.
+           return this.validationGroups;
+        }
+        else if (DEFAULT_VALIDATION_GROUP_NAME.equals(this.validationGroups))
+        {
+            // default validation groups can be saved as null.
+            return null;
+        }
+        else
+        {
+            // Save it fully. Remember that by MYFACES-2528
+            // validationGroups needs to be stored into the state
+            // because this value is often susceptible to use in "combo"
+            return this.validationGroups;
+        }
     }
 
     /** {@inheritDoc} */
     public void restoreState(final FacesContext context, final Object state)
     {
-        this.validationGroups = (String) state;
-
+        if (state != null)
+        {
+            this.validationGroups = (String) state;
+        }
+        else
+        {
+            // When the value is being validated, postSetValidationGroups() sets
+            // validationGroups to javax.validation.groups.Default. 
+            this.validationGroups = null;
+        }
         // Only the String is saved, recalculate the Class[] on state restoration.
         //postSetValidationGroups();
     }
@@ -411,6 +437,7 @@ public class BeanValidator implements Va
     public void setValidationGroups(final String validationGroups)
     {
         this.validationGroups = validationGroups;
+        this.clearInitialState();
         //postSetValidationGroups();
     }
 



Mime
View raw message