details: /erp/devel/pi/rev/4f0bf76a1b92
changeset: 12212:4f0bf76a1b92
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Wed May 18 10:47:49 2011 +0200
summary: Restore JSEXECUTE functionality to the FIC
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 22 +++++++--
1 files changed, 16 insertions(+), 6 deletions(-)
diffs (86 lines):
diff -r ead0927e415d -r 4f0bf76a1b92
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
Wed May 18 09:49:45 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Wed May 18 10:47:49 2011 +0200
@@ -128,6 +128,7 @@
List<String> changeEventCols = new ArrayList<String>();
Map<String, List<String>> columnsInValidation = new HashMap<String,
List<String>>();
List<String> calloutMessages = new ArrayList<String>();
+ List<String> jsExcuteCode = new ArrayList<String>();
log.debug("Form Initialization Component Execution. Tab Name: " +
tab.getWindow().getName()
+ "." + tab.getName() + " Tab Id:" + tab.getId());
@@ -228,7 +229,7 @@
// Execution of callouts
long t6 = System.currentTimeMillis();
List<String> changedCols = executeCallouts(mode, tab, columnValues,
changedColumn,
- calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols);
+ calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols,
jsExcuteCode);
if (changedCols.size() > 0) {
RequestContext.get().setRequestParameter("donotaddcurrentelement",
"true");
@@ -242,7 +243,7 @@
// Construction of the final JSONObject
long t8 = System.currentTimeMillis();
JSONObject finalObject = buildJSONObject(mode, tab, columnValues, row,
changeEventCols,
- calloutMessages, attachments);
+ calloutMessages, attachments, jsExcuteCode);
long t9 = System.currentTimeMillis();
log.debug("Elapsed time: " + (System.currentTimeMillis() - iniTime) +
"(" + (t2 - t1) + ","
+ (t3 - t2) + "," + (t4 - t3) + "," + (t5 - t4) + "," + (t6 - t5) +
"," + (t7 - t6) + ","
@@ -305,7 +306,7 @@
private JSONObject buildJSONObject(String mode, Tab tab, Map<String,
JSONObject> columnValues,
BaseOBObject row, List<String> changeEventCols, List<String>
calloutMessages,
- List<JSONObject> attachments) {
+ List<JSONObject> attachments, List<String> jsExcuteCode) {
JSONObject finalObject = new JSONObject();
try {
if (mode.equals("NEW") || mode.equals("CHANGE")) {
@@ -396,6 +397,9 @@
finalObject.put("attachments", new JSONArray(attachments));
finalObject.put("attachmentExists", attachments.size() > 0);
+ if (!jsExcuteCode.isEmpty()) {
+ finalObject.put("jscode", new JSONArray(jsExcuteCode));
+ }
log.debug(finalObject.toString(1));
return finalObject;
} catch (JSONException e) {
@@ -932,7 +936,7 @@
private List<String> executeCallouts(String mode, Tab tab, Map<String,
JSONObject> columnValues,
String changedColumn, List<String> calloutsToCall, List<String>
lastfieldChanged,
- List<String> messages, List<String> dynamicCols) {
+ List<String> messages, List<String> dynamicCols, List<String>
jsExecuteCode) {
// In CHANGE mode, we will add the initial callout call for the changed
column, if there is
// one
@@ -954,13 +958,13 @@
return new ArrayList<String>();
}
return runCallouts(columnValues, tab, calledCallouts, calloutsToCall,
lastfieldChanged,
- messages, dynamicCols);
+ messages, dynamicCols, jsExecuteCode);
}
private List<String> runCallouts(Map<String, JSONObject> columnValues, Tab
tab,
List<String> calledCallouts, List<String> calloutsToCall, List<String>
lastfieldChangedList,
- List<String> messages, List<String> dynamicCols) {
+ List<String> messages, List<String> dynamicCols, List<String>
jsExecuteCode) {
HashMap<String, Object> calloutInstances = new HashMap<String, Object>();
// flush&commit to release lock in db which otherwise interfere with
callouts which run in their
@@ -1047,6 +1051,12 @@
if (name.equals("MESSAGE")) {
log.debug("Callout message: " + element.get(1, null));
messages.add(element.get(1, null).toString());
+ } else if (name.equals("JSEXECUTE")) {
+ // The code on a JSEXECUTE command is sent directly to the
client for eval()
+ String code = (String) element.get(1, null);
+ if (code != null) {
+ jsExecuteCode.add(code);
+ }
} else if (name.equals("EXECUTE")) {
String js = element.get(1, null) == null ? null :
element.get(1, null).toString();
if (js != null && !js.equals("")) {
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits