Fixed export CSV functionality so that it works with new filtering system
authorAntonio Moreno <antonio.moreno@openbravo.com>
Wed, 09 Mar 2011 11:07:18 +0100
changeset 11132 25c237658226
parent 11131 362e1eb87492
child 11133 007b2aaac1de
child 11140 1a6fae737f2b
Fixed export CSV functionality so that it works with new filtering system
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Wed Mar 09 10:41:14 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Wed Mar 09 11:07:18 2011 +0100
@@ -667,7 +667,11 @@
       var field = document.createElement('input');
       field.setAttribute('type', 'hidden');
       field.setAttribute('name', key);
-      field.setAttribute('value', data[key]);
+      if(isc.isA.Object(data[key])){
+        field.setAttribute('value', isc.JSON.encode(data[key]));
+      }else{
+        field.setAttribute('value', data[key]);
+      }
       OB.GlobalHiddenForm.appendChild(field);
     }
   }
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Wed Mar 09 10:41:14 2011 +0100
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Wed Mar 09 11:07:18 2011 +0100
@@ -277,9 +277,19 @@
       criteria.put("_constructor", "AdvancedCriteria");
 
       final List<JSONObject> criteriaObjects = new ArrayList<JSONObject>();
-      if (parameters.containsKey("criteria")) {
-        final String[] criteriaStrs = parameters.get("criteria").split(
-            JsonConstants.IN_PARAMETER_SEPARATOR);
+      if (parameters.containsKey("criteria") && !parameters.get("criteria").equals("")) {
+        String fullCriteriaStr = parameters.get("criteria");
+        if (fullCriteriaStr.startsWith("[")) {
+          JSONArray criteriaArray = new JSONArray(fullCriteriaStr);
+          fullCriteriaStr = "";
+          for (int i = 0; i < criteriaArray.length(); i++) {
+            if (i > 0) {
+              fullCriteriaStr += JsonConstants.IN_PARAMETER_SEPARATOR;
+            }
+            fullCriteriaStr += criteriaArray.getJSONObject(i).toString();
+          }
+        }
+        final String[] criteriaStrs = fullCriteriaStr.split(JsonConstants.IN_PARAMETER_SEPARATOR);
         for (String criteriaStr : criteriaStrs) {
           final JSONObject criteriaJSONObject = new JSONObject(criteriaStr);
           if (criteriaJSONObject.has("fieldName")) {