empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1387115 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: components/ControlTag.java components/InputTag.java utils/TagEncodingHelper.java
Date Tue, 18 Sep 2012 12:29:56 GMT
Author: doebele
Date: Tue Sep 18 12:29:55 2012
New Revision: 1387115

URL: http://svn.apache.org/viewvc?rev=1387115&view=rev
Log:
EMPIREDB-157 
JSF2: change check for mandatory attribute

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/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=1387115&r1=1387114&r2=1387115&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
Tue Sep 18 12:29:55 2012
@@ -486,7 +486,7 @@ public class ControlTag extends UIInput 
         // check required?
         Object value = getLocalValue();
         // check required
-        if (isEmpty(value) && isPartialSubmit(context) && helper.getColumn().isRequired())
+        if (isEmpty(value) && isPartialSubmit(context) && !helper.isTempoaryNullable())
         {   // Value is null, but required
             log.debug("Skipping model update for {} due to Null value.", inpInfo.getColumn().getName());
             return;

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=1387115&r1=1387114&r2=1387115&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
Tue Sep 18 12:29:55 2012
@@ -218,7 +218,7 @@ public class InputTag extends UIInput im
             return; 
         // check required
         Object value = getLocalValue();
-        if (isEmpty(value) && isPartialSubmit(context) && helper.getColumn().isReadOnly())
+        if (isEmpty(value) && isPartialSubmit(context) && !helper.isTempoaryNullable())
         {   // Value is null, but required
             log.debug("Skipping model update for {} due to Null value.", inpInfo.getColumn().getName());
             return;

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=1387115&r1=1387114&r2=1387115&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
Tue Sep 18 12:29:55 2012
@@ -359,7 +359,7 @@ public class TagEncodingHelper implement
     private Column              column       = null;
     private Object              record       = null;
     private RecordTag           recordTag    = null;
-    private Boolean             tagRequired  = null;
+    // private Boolean          tagRequired  = null;
     private Boolean             hasValueExpr = null;
     private InputControl        control      = null;
     private TextResolver        textResolver = null;
@@ -384,13 +384,14 @@ public class TagEncodingHelper implement
                 ((UIInput)tag).setValue(null);
                 ((UIInput)tag).setLocalValueSet(false);
             }
-            // See if the Input is required 
-            ValueExpression ve = findValueExpression("mandatory", true);
+            /*
+            ValueExpression ve = findValueExpression("required", true);
             if (ve!=null)
             {   Object req = ve.getValue(FacesContext.getCurrentInstance().getELContext());
                 if (req!=null)
                     tagRequired = new Boolean(ObjectUtils.getBoolean(req));
             }
+            */
         }
     }
 
@@ -745,9 +746,10 @@ public class TagEncodingHelper implement
 
     public boolean isValueRequired()
     {
-        // See if the tag is required
-        if (tagRequired!=null)
-            return tagRequired.booleanValue();
+        // See if the tag is required (don't use the "required" attribute or tag.isRequired()!)
+        Object mandatory = getTagAttributeValue("mandatory");
+        if (mandatory!=null)
+            return ObjectUtils.getBoolean(mandatory);
         // Check Read-Only first
         if (isReadOnly())
             return false;
@@ -763,6 +765,16 @@ public class TagEncodingHelper implement
         // Required
         return getColumn().isRequired();
     }
+    
+    /**
+     * used for partial submits to detect whether the value of this field can be set to null
+     */
+    public boolean isTempoaryNullable()
+    {
+        if (getColumn().isRequired())
+            return false;
+        return true;        
+    }
 
     /* Helpers */
     protected Column findColumn()



Mime
View raw message