details:   https://code.openbravo.com/erp/devel/pi/rev/d0cc878c5657
changeset: 33968:d0cc878c5657
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Thu May 17 10:05:57 2018 +0200
summary:   fixes issue 38548: Default Expression in Selector Field does not 
work properly

  After the changes introduced with[1] the request data is send to the 
SelectorDefaultFilterActionHandler as part of the POST payload rather than in 
the query string. This caused that the selector id was not being found in that 
handler, avoiding the correct processing of the data.

  The problem has been fixed by retrieving the data to process both from the 
request parameters and content.

[1] 
https://code.openbravo.com/erp/devel/pi/rev/2a79f597da83870d152ee3176ffa679a01ac19d5

diffstat:

 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java
 |  19 ++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diffs (43 lines):

diff -r 59a5aec24377 -r d0cc878c5657 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java
--- 
a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java
     Wed May 16 17:16:05 2018 +0530
+++ 
b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java
     Thu May 17 10:05:57 2018 +0200
@@ -19,6 +19,7 @@
 package org.openbravo.userinterface.selector;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -58,6 +59,7 @@
     JSONObject result = new JSONObject();
 
     Map<String, String> params = getParameterMap(parameters);
+    addParametersFromRequestContent(params, content);
 
     OBContext.setAdminMode();
 
@@ -163,6 +165,23 @@
     return result;
   }
 
+  private void addParametersFromRequestContent(Map<String, String> params, 
String content) {
+    JSONObject jsonContent;
+    try {
+      jsonContent = new JSONObject(content);
+      @SuppressWarnings("unchecked")
+      Iterator<String> keys = jsonContent.keys();
+      while (keys.hasNext()) {
+        String key = keys.next();
+        String value = jsonContent.getString(key);
+        params.put(key, value);
+      }
+    } catch (JSONException e) {
+      log.error("Could not retrieve JSON from content: " + content);
+      return;
+    }
+  }
+
   private JSONObject createJSONObjectFilter(String fieldName, String id, 
String identifier)
       throws JSONException {
     JSONObject jsonResult = new JSONObject();

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to