details:   /erp/devel/pi/rev/adbb4479b500
changeset: 8510:adbb4479b500
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Thu Oct 07 12:06:37 2010 +0200
summary:   Fixes issue 14422: Fixed getFormat function when returning default 
values

details:   /erp/devel/pi/rev/9aeac6f19649
changeset: 8511:9aeac6f19649
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Thu Oct 07 12:19:00 2010 +0200
summary:   Fixes issue 14459: Sync the JS default format with Java

details:   /erp/devel/pi/rev/e135e54e07cb
changeset: 8512:e135e54e07cb
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Thu Oct 07 16:05:07 2010 +0200
summary:   Issue 13873: Added support for autosave for generated windows in new 
ui

diffstat:

 src-wad/src/org/openbravo/wad/javasource.javaxml   |  33 +++++++++++++++++++++-
 src/org/openbravo/erpCommon/utility/DynamicJS.java |  12 ++++----
 src/org/openbravo/erpCommon/utility/OBError.java   |  10 ++++++
 3 files changed, 48 insertions(+), 7 deletions(-)

diffs (108 lines):

diff -r 979c2d69343d -r e135e54e07cb 
src-wad/src/org/openbravo/wad/javasource.javaxml
--- a/src-wad/src/org/openbravo/wad/javasource.javaxml  Mon Oct 11 13:58:26 
2010 +0530
+++ b/src-wad/src/org/openbravo/wad/javasource.javaxml  Thu Oct 07 16:05:07 
2010 +0200
@@ -29,7 +29,7 @@
 import org.openbravo.erpCommon.ad_actionButton.*;
 </PARAMETER_TMP>
 
-
+import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.erpCommon.utility.*;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.utils.FormatUtilities;
@@ -613,6 +613,37 @@
         if (log4j.isDebugEnabled() &amp;&amp; myError!=null) 
log4j.debug(myError.getMessage());
         printPageClosePopUp(response, vars);
 </FIELDS_TMP>
+    } else if (vars.commandIn("SAVE_XHR")) {
+      <PARAMETER_TMP id="parent">String strP<PARENT_TMP 
id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP 
id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP 
id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
+      OBError myError = new OBError();
+      JSONObject result = new JSONObject();
+      String commandType = vars.getStringParameter("inpCommandType");
+      char saveType = "NEW".equals(commandType) ? 'I' : 'U';
+      try {
+        int total = saveRecord(vars, myError, saveType<PARAMETER_TMP 
id="parent">, strP<PARENT_TMP 
id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
+        if (myError.isEmpty()) {
+          myError = Utility.translateError(this, vars, vars.getLanguage(), 
"@CODE=RowsUpdated");
+          myError.setMessage(total + " " + myError.getMessage());
+          myError.setType("Success");
+        }
+        result.put("oberror", myError.toHashMap());
+        result.put("tabid", vars.getStringParameter("tabID"));
+        result.put("redirect", strDireccion + request.getServletPath() + 
"?Command=" + commandType);
+      } catch (Exception e) {
+        log4j.error("Error saving record (XHR request): " + e.getMessage(), e);
+        try {
+          myError.setType("Error");
+          myError.setMessage(e.getMessage());
+        } catch (Exception e2) {
+          // Ignored
+        }
+      }
+
+      response.setContentType("application/json");
+      PrintWriter out = response.getWriter();
+      out.print(result.toString());
+      out.flush();
+      out.close();
     } else if (vars.getCommand().toUpperCase().startsWith("BUTTON") || 
vars.getCommand().toUpperCase().startsWith("SAVE_BUTTON")) {
       pageErrorPopUp(response);
     } else pageError(response);
diff -r 979c2d69343d -r e135e54e07cb 
src/org/openbravo/erpCommon/utility/DynamicJS.java
--- a/src/org/openbravo/erpCommon/utility/DynamicJS.java        Mon Oct 11 
13:58:26 2010 +0530
+++ b/src/org/openbravo/erpCommon/utility/DynamicJS.java        Thu Oct 07 
16:05:07 2010 +0200
@@ -119,11 +119,11 @@
     String globals = "";
 
     globals += "var decSeparator_global = '"
-        + vars.getSessionValue("#DECIMALSEPARATOR|EUROEDITION") + "';\n";
+        + vars.getSessionValue("#DECIMALSEPARATOR|QTYEDITION") + "';\n";
     globals += "var groupSeparator_global = '"
-        + vars.getSessionValue("#GROUPSEPARATOR|EUROEDITION") + "';\n";
+        + vars.getSessionValue("#GROUPSEPARATOR|QTYEDITION") + "';\n";
     globals += "var groupInterval_global = '3';\n";
-    globals += "var maskNumeric_default = '" + 
vars.getSessionValue("#FORMATOUTPUT|EUROEDITION")
+    globals += "var maskNumeric_default = '" + 
vars.getSessionValue("#FORMATOUTPUT|QTYEDITION")
         + "';\n";
 
     out.print(globals);
@@ -144,11 +144,11 @@
     }
     out.println("]};");
     out.print("F.getFormat=function(name)");
-    out.print("{if(typeof name==='undefined'||name==='')");
-    out.print("{return'qtyEdition';}");
+    out.print("{if(!name)");
+    out.print("{return F.getFormat('qtyEdition');}");
     out.print("for(var i=0;i<this.formats.length;i++)");
     out.print("{if(this.formats[i].name===name)");
-    out.println("{return this.formats[i].output;}}return'qtyEdtion';}");
+    out.println("{return this.formats[i].output;}} return 
F.getFormat('qtyEdtion');};");
 
     out.close();
   }
diff -r 979c2d69343d -r e135e54e07cb 
src/org/openbravo/erpCommon/utility/OBError.java
--- a/src/org/openbravo/erpCommon/utility/OBError.java  Mon Oct 11 13:58:26 
2010 +0530
+++ b/src/org/openbravo/erpCommon/utility/OBError.java  Thu Oct 07 16:05:07 
2010 +0200
@@ -18,6 +18,8 @@
  */
 package org.openbravo.erpCommon.utility;
 
+import java.util.HashMap;
+
 public class OBError {
   private String type = "";
   private String title = "";
@@ -75,4 +77,12 @@
   public boolean isConnectionAvailable() {
     return this.connectionAvailable;
   }
+
+  public HashMap<String, String> toHashMap() {
+    HashMap<String, String> o = new HashMap<String, String>();
+    o.put("title", title);
+    o.put("message", message);
+    o.put("type", type);
+    return o;
+  }
 }

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to