details: /erp/devel/pi/rev/84f13f94e05b
changeset: 10042:84f13f94e05b
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Fri Jan 21 17:30:55 2011 +0100
summary: Now in NEW mode only callouts belonging to list references will be
executed
details: /erp/devel/pi/rev/1e7a125edad0
changeset: 10043:1e7a125edad0
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Fri Jan 21 17:34:59 2011 +0100
summary: Added log to the FIC
details: /erp/devel/pi/rev/63b1ff5072af
changeset: 10044:63b1ff5072af
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Fri Jan 21 18:01:54 2011 +0100
summary: Do not fire callouts if the previous callout didn't actually modify
the value of the field
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 77 +++++----
1 files changed, 41 insertions(+), 36 deletions(-)
diffs (136 lines):
diff -r 1d5862969ab4 -r 63b1ff5072af
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
Fri Jan 21 17:38:41 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Fri Jan 21 18:01:54 2011 +0100
@@ -50,7 +50,6 @@
import org.openbravo.client.kernel.BaseActionHandler;
import org.openbravo.client.kernel.KernelUtils;
import org.openbravo.client.kernel.RequestContext;
-import org.openbravo.client.kernel.reference.FKComboUIDefinition;
import org.openbravo.client.kernel.reference.UIDefinition;
import org.openbravo.client.kernel.reference.UIDefinitionController;
import org.openbravo.dal.core.OBContext;
@@ -115,6 +114,13 @@
log.debug("Form Initialization Component Execution. Tab Name: " +
tab.getWindow().getName()
+ "." + tab.getName() + " Tab Id:" + tab.getId());
+ log.debug("Execution mode: " + mode);
+ if (rowId != null) {
+ log.debug("Row id: " + rowId);
+ }
+ if (changedColumn != null) {
+ log.debug("Changed field: " + changedColumn);
+ }
if (rowId != null) {
row = OBDal.getInstance().get(tab.getTable().getName(), rowId);
}
@@ -322,10 +328,10 @@
jsonobject = new JSONObject(value);
columnValues.put("inp"
+
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()), jsonobject);
- // We need to fire callouts if the field value was changed, or if
the field is a combo
+ // We need to fire callouts if the field is a combo
// (due to how ComboReloads worked, callouts were always called)
- if (mode.equals("NEW")
- && ((jsonobject.has("value") &&
!jsonobject.get("value").equals("")) || uiDef instanceof FKComboUIDefinition)) {
+ if (mode.equals("NEW") &&
(field.getColumn().getReference().getId().equals("17"))) {
+ System.out.println("hola " + field.getName());
if (field.getColumn().getCallout() != null) {
addCalloutToList(field.getColumn(), calloutsToCall,
lastfieldChanged);
}
@@ -646,27 +652,6 @@
private void executeCallouts(String mode, Tab tab, Map<String, JSONObject>
columnValues,
String changedColumn, List<String> calloutsToCall, List<String>
lastfieldChanged,
List<String> messages) {
- // List of the callouts that need to be called
- if (mode.equals("NEW")) {
- for (Field field : tab.getADFieldList()) {
- if (field.getColumn().getCallout() != null) {
- Object value;
- try {
- JSONObject jsonCol = columnValues.get("inp"
- +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()));
- value = jsonCol.has("value") ? jsonCol.get("value") : null;
- if (value != null && !value.toString().equals("")) {
- // There is a callout and the value for this field is set
-
- addCalloutToList(field.getColumn(), calloutsToCall,
lastfieldChanged);
- }
- } catch (JSONException e) {
- log.error("Error reading value from parameter. Not executing
callouts for column "
- + field.getColumn().getDBColumnName(), e);
- }
- }
- }
- }
// In CHANGE mode, we will add the initial callout call for the changed
column, if there is
// one
@@ -766,13 +751,23 @@
if (subelement.get(2,
null).toString().equalsIgnoreCase("True")) {
String value = subelement.get(0, null).toString();
log.debug("Column: " + col.getDBColumnName() + "
Value: " + value);
+ String oldValue = rq.getRequestParameter(colId);
rq.setRequestParameter(colId, value);
UIDefinition uiDef =
UIDefinitionController.getInstance()
.getUIDefinition(col.getId());
JSONObject jsonobject = new
JSONObject(uiDef.getFieldProperties(inpFields
.get(name), true));
- columnValues.put(colId, jsonobject);
- changed = true;
+ String newValue = jsonobject.getString("value");
+ if ((oldValue == null && newValue != null)
+ || (oldValue != null && newValue == null)
+ || (oldValue != null && newValue != null &&
!oldValue
+ .equals(newValue))) {
+ columnValues.put(colId, jsonobject);
+ changed = true;
+ } else {
+ log
+ .debug("Column value didn't change. We do not
attempt to execute any additional callout");
+ }
}
}
} else {
@@ -784,7 +779,7 @@
} else {
value = (String) el;
}
- log.debug("Modified column: " + col.getDBColumnName() +
" Value: " + value);
+ String oldValue = rq.getRequestParameter(colId);
// We set the new value in the request, so that the
JSONObject is computed
// with the new value
rq.setRequestParameter(colId, value);
@@ -792,15 +787,25 @@
col.getId());
JSONObject jsonobj = new
JSONObject(uiDef.getFieldProperties(inpFields
.get(name), true));
- columnValues.put("inp" +
Sqlc.TransformaNombreColumna(col.getDBColumnName()),
- jsonobj);
- changed = true;
+ String newValue = jsonobj.getString("value");
+ log.debug("Modified column: " + col.getDBColumnName() +
" Value: " + value);
+ if ((oldValue == null && newValue != null)
+ || (oldValue != null && newValue == null)
+ || (oldValue != null && newValue != null &&
!oldValue.equals(newValue))) {
+ columnValues.put("inp"
+ +
Sqlc.TransformaNombreColumna(col.getDBColumnName()), jsonobj);
+ changed = true;
- // We set the value as formatted in the JSONObject in
the request, so that the
- // request now is format safe and additional
getFieldProperties calls do not
- // fail
- if (jsonobj.has("value")) {
- rq.setRequestParameter(colId,
jsonobj.getString("value"));
+ // We set the value as formatted in the JSONObject in
the request, so that
+ // the
+ // request now is format safe and additional
getFieldProperties calls do not
+ // fail
+ if (jsonobj.has("value")) {
+ rq.setRequestParameter(colId,
jsonobj.getString("value"));
+ }
+ } else {
+ log
+ .debug("Column value didn't change. We do not
attempt to execute any additional callout");
}
}
if (changed && col.getCallout() != null) {
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits