details: https://code.openbravo.com/erp/devel/pi/rev/339363457926
changeset: 13623:339363457926
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Tue Aug 30 17:49:17 2011 +0200
summary: Fixed issue 18329. Output fields can now be assigned by callouts.
The following changes have been made:
- In the FIC, a new list of hidden fields is maintained. This list is filled
with every response item produced by a callout which starts by 'inp', and
doesn't correspond to a column name, or auxiliary input name. These items are
written to the request so that subsequent callouts can use them.
- In the client, in the processFICRequest method, this list will be read, and
its values will be set in the hiddenInputs object of the form.
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 35 ++++++++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
| 9 ++-
2 files changed, 37 insertions(+), 7 deletions(-)
diffs (123 lines):
diff -r 395ce0ebf3e4 -r 339363457926
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
Tue Aug 30 13:56:35 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Tue Aug 30 17:49:17 2011 +0200
@@ -134,6 +134,7 @@
Map<String, List<String>> columnsInValidation = new HashMap<String,
List<String>>();
List<JSONObject> calloutMessages = new ArrayList<JSONObject>();
List<String> jsExcuteCode = new ArrayList<String>();
+ Map<String, Object> hiddenInputs = new HashMap<String, Object>();
log.debug("Form Initialization Component Execution. Tab Name: " +
tab.getWindow().getName()
+ "." + tab.getName() + " Tab Id:" + tab.getId());
@@ -234,7 +235,8 @@
// Execution of callouts
long t6 = System.currentTimeMillis();
List<String> changedCols = executeCallouts(mode, tab, columnValues,
changedColumn,
- calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols,
jsExcuteCode);
+ calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols,
jsExcuteCode,
+ hiddenInputs);
if (changedCols.size() > 0) {
RequestContext.get().setRequestParameter("donotaddcurrentelement",
"true");
@@ -248,7 +250,7 @@
// Construction of the final JSONObject
long t8 = System.currentTimeMillis();
JSONObject finalObject = buildJSONObject(mode, tab, columnValues, row,
changeEventCols,
- calloutMessages, attachments, jsExcuteCode);
+ calloutMessages, attachments, jsExcuteCode, hiddenInputs);
long t9 = System.currentTimeMillis();
log.debug("Elapsed time: " + (System.currentTimeMillis() - iniTime) +
"(" + (t2 - t1) + ","
+ (t3 - t2) + "," + (t4 - t3) + "," + (t5 - t4) + "," + (t6 - t5) +
"," + (t7 - t6) + ","
@@ -310,12 +312,19 @@
private JSONObject buildJSONObject(String mode, Tab tab, Map<String,
JSONObject> columnValues,
BaseOBObject row, List<String> changeEventCols, List<JSONObject>
calloutMessages,
- List<JSONObject> attachments, List<String> jsExcuteCode) {
+ List<JSONObject> attachments, List<String> jsExcuteCode, Map<String,
Object> hiddenInputs) {
JSONObject finalObject = new JSONObject();
try {
if (mode.equals("NEW") || mode.equals("CHANGE")) {
JSONArray arrayMessages = new JSONArray(calloutMessages);
finalObject.put("calloutMessages", arrayMessages);
+ if (!hiddenInputs.isEmpty()) {
+ JSONObject jsonHiddenInputs = new JSONObject();
+ for (String key : hiddenInputs.keySet()) {
+ jsonHiddenInputs.put(key, hiddenInputs.get(key));
+ }
+ finalObject.put("hiddenInputs", jsonHiddenInputs);
+ }
}
if (mode.equals("NEW") || mode.equals("EDIT") || mode.equals("CHANGE")) {
JSONObject jsonColumnValues = new JSONObject();
@@ -959,7 +968,8 @@
private List<String> executeCallouts(String mode, Tab tab, Map<String,
JSONObject> columnValues,
String changedColumn, List<String> calloutsToCall, List<String>
lastfieldChanged,
- List<JSONObject> messages, List<String> dynamicCols, List<String>
jsExecuteCode) {
+ List<JSONObject> messages, List<String> dynamicCols, List<String>
jsExecuteCode,
+ Map<String, Object> hiddenInputs) {
// In CHANGE mode, we will add the initial callout call for the changed
column, if there is
// one
@@ -981,13 +991,14 @@
return new ArrayList<String>();
}
return runCallouts(columnValues, tab, calledCallouts, calloutsToCall,
lastfieldChanged,
- messages, dynamicCols, jsExecuteCode);
+ messages, dynamicCols, jsExecuteCode, hiddenInputs);
}
private List<String> runCallouts(Map<String, JSONObject> columnValues, Tab
tab,
List<String> calledCallouts, List<String> calloutsToCall, List<String>
lastfieldChangedList,
- List<JSONObject> messages, List<String> dynamicCols, List<String>
jsExecuteCode) {
+ List<JSONObject> messages, List<String> dynamicCols, List<String>
jsExecuteCode,
+ Map<String, Object> hiddenInputs) {
HashMap<String, Object> calloutInstances = new HashMap<String, Object>();
// flush&commit to release lock in db which otherwise interfere with
callouts which run in their
@@ -1206,6 +1217,18 @@
columnValues.put(name, obj);
}
}
+ if (!columnValues.containsKey(name)) {
+ // This returned value wasn't found to be either a
column or an auxiliary
+ // input. We assume it is a hidden input, which are used
in places like
+ // selectors
+ Object el = element.get(1, null);
+ if (el != null) {
+ hiddenInputs.put(name, el);
+ // We set the hidden fields in the request, so that
subsequent callouts can
+ // use them
+ rq.setRequestParameter(name, el.toString());
+ }
+ }
}
}
}
diff -r 395ce0ebf3e4 -r 339363457926
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
Tue Aug 30 13:56:35 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
Tue Aug 30 17:49:17 2011 +0200
@@ -595,7 +595,8 @@
var columnValues = data.columnValues, calloutMessages =
data.calloutMessages,
auxInputs = data.auxiliaryInputValues, prop, value, i,
j,
dynamicCols = data.dynamicCols,
- sessionAttributes = data.sessionAttributes, item,
section;
+ sessionAttributes = data.sessionAttributes, item,
section,
+ retHiddenInputs = data.hiddenInputs;
// edit row has changed when returning, don't update the form anymore
if (this.grid && this.grid.getEditRow() !== editRow) {
@@ -621,6 +622,12 @@
}
}
+ if(retHiddenInputs) {
+ for(prop in retHiddenInputs) {
+ this.hiddenInputs[prop] = retHiddenInputs[prop];
+ }
+ }
+
if(this.attachmentsSection) {
this.attachmentsSection.fillAttachments(data.attachments);
}
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits