details:   /erp/devel/pi/rev/0f73751338d6
changeset: 10424:0f73751338d6
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Tue Feb 08 10:11:16 2011 +0100
summary:   Readded createFromClassicString() in NumberUIDefinition, but with 
correct parsing

details:   /erp/devel/pi/rev/244cd2044bb2
changeset: 10425:244cd2044bb2
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Tue Feb 08 12:23:48 2011 +0100
summary:   Modified FIC and UIDef so that in request, there are always classic 
values, and in jsonobjects, objects

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  23 +++++----
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
                 |  15 ++++++
 2 files changed, 27 insertions(+), 11 deletions(-)

diffs (90 lines):

diff -r b7db4752b716 -r 244cd2044bb2 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Tue Feb 08 12:15:01 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Tue Feb 08 12:23:48 2011 +0100
@@ -40,6 +40,7 @@
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
+import org.openbravo.base.model.domaintype.PrimitiveDomainType;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.structure.ClientEnabled;
 import org.openbravo.base.structure.OrganizationEnabled;
@@ -794,9 +795,13 @@
                           String value = subelement.get(0, null).toString();
                           log.debug("Column: " + col.getDBColumnName() + "  
Value: " + value);
                           String oldValue = rq.getRequestParameter(colId);
-                          rq.setRequestParameter(colId, value);
                           UIDefinition uiDef = 
UIDefinitionController.getInstance()
                               .getUIDefinition(col.getId());
+                          if (uiDef.getDomainType() instanceof 
PrimitiveDomainType) {
+                            rq.setRequestParameter(colId, 
uiDef.convertToClassicString(value));
+                          } else {
+                            rq.setRequestParameter(colId, value == null ? null 
: value.toString());
+                          }
                           JSONObject jsonobject = new 
JSONObject(uiDef.getFieldProperties(inpFields
                               .get(name), true));
                           if (jsonobject.has("classicValue")) {
@@ -820,25 +825,21 @@
                     } else {
                       // Normal data
                       Object el = element.get(1, null);
-                      String value;
-                      if (el instanceof Number) {
-                        value = ((Number) el).toString();
-                      } else {
-                        value = (String) el;
-                      }
                       String oldValue = rq.getRequestParameter(colId);
                       // We set the new value in the request, so that the 
JSONObject is computed
                       // with the new value
-                      rq.setRequestParameter(colId, value);
                       UIDefinition uiDef = 
UIDefinitionController.getInstance().getUIDefinition(
                           col.getId());
+                      if (uiDef.getDomainType() instanceof 
PrimitiveDomainType) {
+                        rq.setRequestParameter(colId, 
uiDef.convertToClassicString(el));
+                      } else {
+                        rq.setRequestParameter(colId, el == null ? null : 
el.toString());
+                      }
                       JSONObject jsonobj = new 
JSONObject(uiDef.getFieldProperties(inpFields
                           .get(name), true));
                       if (jsonobj.has("classicValue")) {
                         String newValue = jsonobj.getString("classicValue");
-                        log
-                            .debug("Modified column: " + col.getDBColumnName() 
+ "  Value: "
-                                + value);
+                        log.debug("Modified column: " + col.getDBColumnName() 
+ "  Value: " + el);
                         if ((oldValue == null && newValue != null)
                             || (oldValue != null && newValue == null)
                             || (oldValue != null && newValue != null && 
!oldValue.equals(newValue))) {
diff -r b7db4752b716 -r 244cd2044bb2 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
     Tue Feb 08 12:15:01 2011 +0100
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
     Tue Feb 08 12:23:48 2011 +0100
@@ -18,6 +18,8 @@
  */
 package org.openbravo.client.kernel.reference;
 
+import java.math.BigDecimal;
+
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.base.exception.OBException;
@@ -119,6 +121,19 @@
   }
 
   @Override
+  protected Object createFromClassicString(String value) {
+    if (value == null || value.length() == 0) {
+      return "";
+    }
+    String valueStr = value.toString();
+    VariablesSecureApp variables = 
RequestContext.get().getVariablesSecureApp();
+    valueStr = valueStr.replace(
+        variables.getSessionValue("#GroupSeparator|" + 
getFormat()).substring(0, 1), "").replace(
+        variables.getSessionValue("#DecimalSeparator|" + 
getFormat()).substring(0, 1), ".");
+    return new BigDecimal(valueStr);
+  }
+
+  @Override
   public String convertToClassicString(Object value) {
     if (value == null) {
       return "";

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to