empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1378230 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: components/ControlTag.java components/InputTag.java controls/InputControl.java controls/TextInputControl.java utils/TagEncodingHelper.java
Date Tue, 28 Aug 2012 17:02:35 GMT
Author: doebele
Date: Tue Aug 28 17:02:34 2012
New Revision: 1378230

URL: http://svn.apache.org/viewvc?rev=1378230&view=rev
Log:
EMPIREDB-165
new attribute on input and control tag "detectFieldChange"

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/InputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.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=1378230&r1=1378229&r2=1378230&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 Aug 28 17:02:34 2012
@@ -32,6 +32,8 @@ import javax.faces.context.ResponseWrite
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.Column;
+import org.apache.empire.db.exceptions.FieldIllegalValueException;
+import org.apache.empire.exceptions.EmpireException;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
 import org.slf4j.Logger;
@@ -466,6 +468,9 @@ public class ControlTag extends UIInput 
             
         } catch(Exception e) {
             // Value is not valid
+            if (!(e instanceof EmpireException))
+                e = new FieldIllegalValueException(helper.getColumn(), "", e);
+            // Add error message
             helper.addErrorMessage(context, e);
             setValid(false);
         }

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=1378230&r1=1378229&r2=1378230&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 Aug 28 17:02:34 2012
@@ -27,6 +27,8 @@ import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
 import org.apache.empire.data.Column;
+import org.apache.empire.db.exceptions.FieldIllegalValueException;
+import org.apache.empire.exceptions.EmpireException;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
 import org.slf4j.Logger;
@@ -197,6 +199,9 @@ public class InputTag extends UIInput im
             
         } catch(Exception e) {
             // Value is not valid
+            if (!(e instanceof EmpireException))
+                e = new FieldIllegalValueException(helper.getColumn(), "", e);
+            // Add error message
             helper.addErrorMessage(context, e);
             setValid(false);
         }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java?rev=1378230&r1=1378229&r2=1378230&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
Tue Aug 28 17:02:34 2012
@@ -448,19 +448,17 @@ public abstract class InputControl
         copyAttribute(ii, input, "style");
         copyAttribute(ii, input, "tabindex");
         copyAttribute(ii, input, "onchange");
-        
+
+        // immediate
+        Object immediate = ii.getAttribute("immediate");
+        if (immediate!=null && ObjectUtils.getBoolean(immediate))
+        {
+            log.warn("Immediate attribute is not yet supported for {}!", ii.getColumn().getName());
+            // input.setImmediate(true);
+        }    
+
         // validator
         // input.addValidator(new ColumnValueValidator(ii.getColumn()));
-        
-        // IceFaces special
-        /*
-        if (input instanceof IceExtended)
-        {   // partialSubmit
-            Object v = parent.getAttributes().get("partialSubmit");
-            if (v!=null)
-               ((IceExtended)input).setPartialSubmit(ObjectUtils.getBoolean(v));
-        }
-        */
     }
 
     protected final void copyAttributes(UIComponent parent, InputInfo ii, UIInput input)

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java?rev=1378230&r1=1378229&r2=1378230&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
Tue Aug 28 17:02:34 2012
@@ -263,7 +263,7 @@ public class TextInputControl extends In
     protected Object formatInputValue(Object value, InputInfo ii)
     {
         if (value == null)
-            return value;
+            return "";
         // Check options
         Options options = ii.getOptions();
         if (options != null && !options.isEmpty())

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=1378230&r1=1378229&r2=1378230&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 Aug 28 17:02:34 2012
@@ -321,6 +321,7 @@ public class TagEncodingHelper implement
     private Boolean             hasValueExpr = null;
     private InputControl        control      = null;
     private TextResolver        textResolver = null;
+    private Object              mostRecentValue = null;
 
     public TagEncodingHelper(UIOutput tag, String tagCssStyle)
     {
@@ -466,6 +467,7 @@ public class TagEncodingHelper implement
     public void setRecord(Object record)
     {
         this.record = record;
+        this.mostRecentValue = null; 
     }
 
     public RecordTag getRecordComponent()
@@ -488,14 +490,23 @@ public class TagEncodingHelper implement
         }
         return null;
     }
+    
+    private boolean isDetectFieldChange()
+    {
+        Object v = this.getTagAttribute("detectFieldChange");
+        if (v==null && recordTag != null)
+            v = recordTag.getAttributes().get("detectFieldChange");
+        return (v!=null ? ObjectUtils.getBoolean(v) : true);
+    }
 
     public Object getDataValue(boolean evalExpression)
     {
         if (getRecord() != null)
-        { // value
+        {   // value
             if (record instanceof RecordData)
             { // a record
-                return ((RecordData) record).getValue(getColumn());
+                mostRecentValue = ((RecordData) record).getValue(getColumn());
+                return mostRecentValue;
             }
             else
             { // a normal bean
@@ -533,6 +544,15 @@ public class TagEncodingHelper implement
                     return;
                 }
                 */
+                if (isDetectFieldChange())
+                {   // DetectFieldChange by comparing current and most recent value
+                    Object currentValue = ((Record) record).getValue(getColumn());
+                    if (!ObjectUtils.compareEqual(currentValue, mostRecentValue))
+                    {   // Value has been changed by someone else!
+                        log.info("Concurrent data change for "+getColumn().getName()+". Current
Value is {}. Ignoring new value {}", currentValue, value);
+                        return;
+                    }
+                }
                 // a record
                 ((Record) record).setValue(getColumn(), value);
             }



Mime
View raw message