details: https://code.openbravo.com/erp/devel/pi/rev/8780b0463263
changeset: 22761:8780b0463263
user: Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date: Mon Mar 24 16:33:35 2014 +0530
summary: Fixes Issue 0025754, Fixes Issue 25359: Property fields are
evaluated on NEW request
When a new record is created, property fields were not evaluated and default
values were sent.
Now the property fields are tried to be evaluated, if value is not found, null
is returned.
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 70 ++++++---
1 files changed, 47 insertions(+), 23 deletions(-)
diffs (83 lines):
diff -r 69c758824b3e -r 8780b0463263
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 Mar 24 11:56:34 2014 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Mon Mar 24 16:33:35 2014 +0530
@@ -608,32 +608,56 @@
if (mode.equals("NEW")) {
// On NEW mode, the values are computed through the UIDefinition
(the defaults will be
// used)
- if (field.getColumn().isLinkToParentColumn() && parentRecord != null
- && referencedEntityIsParent(parentRecord, field)) {
- // If the column is link to the parent tab, we set its value as
the parent id
- RequestContext.get().setRequestParameter("inp" +
Sqlc.TransformaNombreColumna(col),
- parentId);
- value = uiDef.getFieldProperties(field, true);
- } else if
(field.getColumn().getDBColumnName().equalsIgnoreCase("IsActive")) {
- // The Active column is always set to 'true' on new records
- RequestContext.get()
- .setRequestParameter("inp" +
Sqlc.TransformaNombreColumna(col), "Y");
- value = uiDef.getFieldProperties(field, true);
+ if (field.getProperty() != null && !field.getProperty().isEmpty()) {
+ // if the column is a property we try to compute the property
value, if value is not
+ // found null is passed. Refer issue
https://issues.openbravo.com/view.php?id=25754
+ Object propertyValue = DalUtil.getValueFromPath(parentRecord,
field.getProperty());
+ if (propertyValue != null) {
+ JSONObject jsonObject = new JSONObject();
+ if (propertyValue instanceof BaseOBObject) {
+ jsonObject.put("value", ((BaseOBObject)
propertyValue).getId());
+ jsonObject.put("classicValue", ((BaseOBObject)
propertyValue).getId());
+ ArrayList<JSONObject> comboEntries = new
ArrayList<JSONObject>();
+ JSONObject entries = new JSONObject();
+ entries.put("id", ((BaseOBObject) propertyValue).getId());
+ entries.put("_identifier", ((BaseOBObject)
propertyValue).getIdentifier());
+ comboEntries.add(entries);
+ jsonObject.put("entries", new JSONArray(comboEntries));
+ } else {
+ jsonObject.put("value", propertyValue.toString());
+ jsonObject.put("classicValue", propertyValue.toString());
+ }
+ value = jsonObject.toString();
+ }
} else {
- // Else, the default is used
- if (isNotActiveOrVisibleAndNotNeeded(field, visibleProperties)) {
- // If the column is not currently visible, and its not
mandatory, we don't need to
- // compute the combo.
- // If a column is mandatory then the combo needs to be computed,
because the selected
- // value can depend on the computation if there is no default
value
- log.debug("Not calculating combo in " + mode + " mode for column
" + col);
- value = uiDef.getFieldPropertiesWithoutCombo(field, false);
+ if (field.getColumn().isLinkToParentColumn() && parentRecord !=
null
+ && referencedEntityIsParent(parentRecord, field)) {
+ // If the column is link to the parent tab, we set its value as
the parent id
+ RequestContext.get().setRequestParameter("inp" +
Sqlc.TransformaNombreColumna(col),
+ parentId);
+ value = uiDef.getFieldProperties(field, true);
+ } else if
(field.getColumn().getDBColumnName().equalsIgnoreCase("IsActive")) {
+ // The Active column is always set to 'true' on new records
+ RequestContext.get().setRequestParameter("inp" +
Sqlc.TransformaNombreColumna(col),
+ "Y");
+ value = uiDef.getFieldProperties(field, true);
} else {
- if (isNotActiveOrVisible(field, visibleProperties)) {
- log.debug("Only first combo record in " + mode + " mode for
column " + col);
- value = uiDef.getFieldPropertiesFirstRecord(field, false);
+ // Else, the default is used
+ if (isNotActiveOrVisibleAndNotNeeded(field, visibleProperties)) {
+ // If the column is not currently visible, and its not
mandatory, we don't need to
+ // compute the combo.
+ // If a column is mandatory then the combo needs to be
computed, because the
+ // selected
+ // value can depend on the computation if there is no default
value
+ log.debug("Not calculating combo in " + mode + " mode for
column " + col);
+ value = uiDef.getFieldPropertiesWithoutCombo(field, false);
} else {
- value = uiDef.getFieldProperties(field, false);
+ if (isNotActiveOrVisible(field, visibleProperties)) {
+ log.debug("Only first combo record in " + mode + " mode for
column " + col);
+ value = uiDef.getFieldPropertiesFirstRecord(field, false);
+ } else {
+ value = uiDef.getFieldProperties(field, false);
+ }
}
}
}
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits