empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1386597 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: components/ControlTag.java components/InputTag.java controls/SelectInputControl.java utils/TagEncodingHelper.java
Date Mon, 17 Sep 2012 13:11:43 GMT
Author: doebele
Date: Mon Sep 17 13:11:42 2012
New Revision: 1386597

URL: http://svn.apache.org/viewvc?rev=1386597&view=rev
Log:
EMPIREDB-157 
JSF2 skip validation for null values in partial requests

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java?rev=1386597&r1=1386596&r2=1386597&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
Mon Sep 17 13:11:42 2012
@@ -439,9 +439,9 @@ public class ControlTag extends UIInput 
     {   // Check state
         if (inpInfo==null || !isValid())
             return;
-        // Skip Null values if not required
-        if (hasRequiredFlagSet && !isRequired() && isEmpty(value)) //  &&
helper.isValueRequired()
-        {   // Value is null, but not required
+        // Skip Null values on partial submit
+        if (isEmpty(value) && isPartialSubmit(context)) //  && helper.isValueRequired()
+        {   // Value is null
             log.debug("Skipping validation for {} due to Null value.", inpInfo.getColumn().getName());
             return;
         }
@@ -486,8 +486,8 @@ public class ControlTag extends UIInput 
         // check required?
         Object value = getLocalValue();
         // check required
-        if (hasRequiredFlagSet && !isRequired() && isEmpty(value) &&
helper.isValueRequired())
-        {   // Value is null, but not required
+        if (isEmpty(value) && isPartialSubmit(context) && helper.getColumn().isRequired())
+        {   // Value is null, but required
             log.debug("Skipping model update for {} due to Null value.", inpInfo.getColumn().getName());
             return;
         }
@@ -516,6 +516,15 @@ public class ControlTag extends UIInput 
         return helper.isValueRequired();
     }
 
+    private boolean isPartialSubmit(FacesContext context)
+    {
+        // Check Required Flag
+        if (hasRequiredFlagSet && !isRequired())
+            return true;
+        // partial  
+        return helper.isPartialSubmit(context);
+    }
+
     /**
      * Check the parent allows the creation of a if the ValueOutputComponent.
      * This method should never return false. If it does, the method "helper.isRecordReadOnly()"
does not return the same value for subsequent calls as when the component was first encoded.

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java?rev=1386597&r1=1386596&r2=1386597&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
Mon Sep 17 13:11:42 2012
@@ -172,8 +172,8 @@ public class InputTag extends UIInput im
         if (inpInfo==null)
             return;
         // Skip Null values if not required
-        if (hasRequiredFlagSet && !isRequired() && isEmpty(value)) //  &&
helper.isValueRequired()
-        {   // Value is null, but not required
+        if (isEmpty(value) && isPartialSubmit(context)) //  && helper.isValueRequired()
+        {   // Value is null
             log.debug("Skipping validation for {} due to Null value.", inpInfo.getColumn().getName());
             return;
         }
@@ -218,8 +218,8 @@ public class InputTag extends UIInput im
             return; 
         // check required
         Object value = getLocalValue();
-        if (hasRequiredFlagSet && !isRequired() && isEmpty(value) &&
helper.isValueRequired())
-        {   // Value is null, but not required
+        if (isEmpty(value) && isPartialSubmit(context) && helper.getColumn().isReadOnly())
+        {   // Value is null, but required
             log.debug("Skipping model update for {} due to Null value.", inpInfo.getColumn().getName());
             return;
         }
@@ -247,6 +247,15 @@ public class InputTag extends UIInput im
         return helper.isValueRequired();
     }
 
+    private boolean isPartialSubmit(FacesContext context)
+    {
+        // Check Required Flag
+        if (hasRequiredFlagSet && !isRequired())
+            return true;
+        // partial  
+        return helper.isPartialSubmit(context);
+    }
+
     /**
      * write value element
      * @param vi

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java?rev=1386597&r1=1386596&r2=1386597&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
Mon Sep 17 13:11:42 2012
@@ -113,6 +113,7 @@ public class SelectInputControl extends 
 
         // style
         addRemoveDisabledStyle(input, input.isDisabled());
+        addRemoveInvalidStyle(input, ii.hasError());
         
         // Set Value
         setInputValue(input, ii);

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java?rev=1386597&r1=1386596&r2=1386597&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
Mon Sep 17 13:11:42 2012
@@ -500,6 +500,11 @@ public class TagEncodingHelper implement
         // create
         return new InputInfoImpl(getColumn(), getTextResolver(ctx));
     }
+    
+    public boolean isPartialSubmit(FacesContext ctx)
+    {
+        return FacesUtils.getFacesApplication().isPartialSubmit(ctx);
+    }
 
     public boolean isSkipValidation()
     {



Mime
View raw message