myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1793916 - in /myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component: UIInput.java html/_HtmlSelectOneRadio.java
Date Thu, 04 May 2017 22:40:01 GMT
Author: lu4242
Date: Thu May  4 22:40:01 2017
New Revision: 1793916

URL: http://svn.apache.org/viewvc?rev=1793916&view=rev
Log:
small fix add javax.faces.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE and fix clirr on
"group" h:selectOneRadio

Modified:
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIInput.java
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/html/_HtmlSelectOneRadio.java

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIInput.java?rev=1793916&r1=1793915&r2=1793916&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIInput.java Thu May
 4 22:40:01 2017
@@ -85,6 +85,9 @@ public class UIInput extends UIOutput im
     private static final String EMPTY_VALUES_AS_NULL_PARAM_NAME
             = "javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL";
 
+    public static final String ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE 
+            = "javax.faces.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE";
+    
     // our own, cached key
     private static final String MYFACES_EMPTY_VALUES_AS_NULL_PARAM_NAME =
       "org.apache.myfaces.UIInput.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL";
@@ -549,6 +552,44 @@ public class UIInput extends UIOutput im
 
         return validateEmptyFields;
     }
+    
+    private boolean shouldAlwaysPerformValidationWhenRequiredTrue(FacesContext context)
+    {
+        ExternalContext ec = context.getExternalContext();
+        Boolean alwaysPerformValidationWhenRequiredTrue = (Boolean) ec.getApplicationMap().get(
+                ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE);
+
+        if (alwaysPerformValidationWhenRequiredTrue == null)
+        {
+             String param = ec.getInitParameter(ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE);
+
+             // null means the same as auto.
+             if (param == null)
+             {
+                 param = "false";
+             }
+             else
+             {
+                 // The environment variables are case insensitive.
+                 param = param.toLowerCase();
+             }
+
+             if (param.equals("true"))
+             {
+                 alwaysPerformValidationWhenRequiredTrue = true;
+             }
+             else
+             {
+                 alwaysPerformValidationWhenRequiredTrue = false;
+             }
+
+             // cache the parsed value
+             ec.getApplicationMap().put(ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE,

+                     alwaysPerformValidationWhenRequiredTrue);
+        }
+
+        return alwaysPerformValidationWhenRequiredTrue;
+    }
 
     /**
      * Determine whether the new value is valid, and queue a ValueChangeEvent if necessary.
@@ -581,7 +622,14 @@ public class UIInput extends UIOutput im
         Object submittedValue = getSubmittedValue();
         if (submittedValue == null)
         {
-            return;
+            if (isRequired() && shouldAlwaysPerformValidationWhenRequiredTrue(context))
+            {
+                // continue
+            }
+            else
+            {
+                return;
+            }
         }
 
         // Begin new JSF 2.0 requirement (INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL)

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/html/_HtmlSelectOneRadio.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/html/_HtmlSelectOneRadio.java?rev=1793916&r1=1793915&r2=1793916&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/html/_HtmlSelectOneRadio.java
(original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/html/_HtmlSelectOneRadio.java
Thu May  4 22:40:01 2017
@@ -21,6 +21,7 @@ package javax.faces.component.html;
 import javax.faces.component.UISelectOne;
 
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
 
 /**
  * Allow the user to choose one option from a set of options.
@@ -77,4 +78,11 @@ _LabelProperty, _RoleProperty
    */
   public abstract String getLayout();
 
+  /**
+   * 
+   * @since 2.3
+   * @return 
+   */
+  @JSFProperty
+  public abstract String getGroup();
 }



Mime
View raw message