You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2012/08/17 15:02:57 UTC

svn commit: r1374235 - in /empire-db/trunk: empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ empire-db/src/main/java/org/apache/empire/db/

Author: doebele
Date: Fri Aug 17 13:02:57 2012
New Revision: 1374235

URL: http://svn.apache.org/viewvc?rev=1374235&view=rev
Log:
EMPIREDB-158
adjust log level and perform checks

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/utils/TagEncodingHelper.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.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=1374235&r1=1374234&r2=1374235&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 Fri Aug 17 13:02:57 2012
@@ -358,7 +358,7 @@ public class ControlTag extends UIInput 
         throws IOException
     {
         // render components
-        if (helper.isRecordReadOnly())
+        if (helper.isRecordReadOnly() && allowValueComponent(parent))
         {
             ValueOutputComponent valueComp = null;
             if (parent.getChildCount()>0)
@@ -470,4 +470,15 @@ public class ControlTag extends UIInput 
     {
         return helper.isValueRequired();
     }
+
+    /**
+     * 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.
+     * @param parent the parent tag
+     * @return true on success or false if the parent's first child is not a instance of ValueOutputComponent
+     */
+    private boolean allowValueComponent(UIComponentBase parent)
+    {
+        return (parent.getChildCount()>0 ? (parent.getChildren().get(0) instanceof ValueOutputComponent) : true); 
+    }
 }

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=1374235&r1=1374234&r2=1374235&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 Fri Aug 17 13:02:57 2012
@@ -577,7 +577,7 @@ public class TagEncodingHelper implement
         // See if we have a record parent
         if (isReadOnly())
             return false;
-        if (hasValueAttribute() && hasValueExpr.booleanValue())
+        if (hasValueAttribute() && (hasValueExpr==null || hasValueExpr.booleanValue()))
             return false;
         // Required
         return column.isRequired();
@@ -677,10 +677,14 @@ public class TagEncodingHelper implement
     
     protected boolean hasValueAttribute()
     {
+        /* this does not work - nor might it be necessary
         // direct value is set (no expression)
-        Object v = tag.getLocalValue();
-        if (v!=null) // tag.getAttributes().containsKey("value"))
+        if (tag.getAttributes().containsKey("value"))
             return true;
+        Object v = tag.getLocalValue(); // will be set for input controls that have an error set
+        if (v!=null)
+            v=null;
+        */    
         // Find expression
         if (hasValueExpr != null)
             return hasValueExpr.booleanValue();

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java?rev=1374235&r1=1374234&r2=1374235&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java Fri Aug 17 13:02:57 2012
@@ -337,7 +337,7 @@ public class DBTableColumn extends DBCol
                         // OK
                     } catch (ParseException e)
                     {   // Error
-                        log.error("checkValue failed: " + e.toString() + " column=" + getName() + " value=" + value);
+                        log.info("checkValue failed: " + e.toString() + " column=" + getName() + " value=" + value);
                         throw new FieldIllegalValueException(this, String.valueOf(value), e);
                     }
                 }    
@@ -354,7 +354,7 @@ public class DBTableColumn extends DBCol
                         // thows NumberFormatException if not a number!
                     } catch (NumberFormatException e)
                     {
-                        log.error("checkValue exception: " + e.toString() + " column=" + getName() + " value=" + value);
+                        log.info("checkValue failed: " + e.toString() + " column=" + getName() + " value=" + value);
                         throw new FieldIllegalValueException(this, String.valueOf(value), e);
                     }
                 }
@@ -370,7 +370,7 @@ public class DBTableColumn extends DBCol
                         // throws NumberFormatException if not an integer!
                     } catch (NumberFormatException e)
                     {
-                        log.error("checkValue exception: " + e.toString() + " column=" + getName() + " value=" + String.valueOf(value));
+                        log.info("checkValue failed: " + e.toString() + " column=" + getName() + " value=" + String.valueOf(value));
                         throw new FieldIllegalValueException(this, String.valueOf(value), e);
                     }
                 }