details:   /erp/devel/pi/rev/b230ed20baca
changeset: 9869:b230ed20baca
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Jan 17 15:55:32 2011 +0100
summary:   Add special parameters to the request so callouts can use them

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  23 +++++++++-
 1 files changed, 21 insertions(+), 2 deletions(-)

diffs (54 lines):

diff -r bcf2d9cce366 -r b230ed20baca 
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
     Mon Jan 17 15:49:43 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Mon Jan 17 15:55:32 2011 +0100
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -140,6 +141,9 @@
             log.error("Couldn't read column value from the request for column 
" + inpColName, e);
           }
         }
+        // We also add special parameters such as the one set by selectors to 
the request, so the
+        // callouts can use them
+        addSpecialParameters(tab, jsContent);
       }
       HashMap<String, JSONObject> columnValues = new HashMap<String, 
JSONObject>();
       HashMap<String, Field> columnsOfFields = new HashMap<String, Field>();
@@ -397,6 +401,23 @@
     return null;
   }
 
+  private void addSpecialParameters(Tab tab, JSONObject jsContent) {
+    Iterator it = jsContent.keys();
+    while (it.hasNext()) {
+      String key = it.next().toString();
+      try {
+        if (RequestContext.get().getRequestParameter(key) == null) {
+          RequestContext.get().setRequestParameter(key, 
jsContent.getString(key));
+        }
+      } catch (JSONException e) {
+        log.error("Couldn't read parameter from the request: " + key, e);
+      }
+    }
+
+    RequestContext.get().setRequestParameter("inpwindowId", 
tab.getWindow().getId());
+    RequestContext.get().setRequestParameter("inpTabId", tab.getId());
+  }
+
   private boolean referencedEntityIsParent(BaseOBObject parentRecord, Field 
field) {
     Entity parentEntity = parentRecord.getEntity();
     Entity entity = ModelProvider.getInstance().getEntityByTableId(
@@ -639,8 +660,6 @@
           // We first prepare the data so that it's usable by the callout
           formatColumnValues(columnValues, fields);
           RequestContext.get().setRequestParameter("inpLastFieldChanged", 
lastFieldChanged);
-          RequestContext.get().setRequestParameter("inpwindowId", 
tab.getWindow().getId());
-          RequestContext.get().setRequestParameter("inpTabId", tab.getId());
           // We then execute the callout
           CalloutServletConfig config = new 
CalloutServletConfig(calloutClassName, RequestContext
               .getServletContext());

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to