details: /erp/devel/pi/rev/1d1c5fb4c601
changeset: 12095:1d1c5fb4c601
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Wed May 11 13:34:39 2011 +0200
summary: Fixed issue 17111. Combos will not be computed if the corresponding
field is not shown and is not mandatory.
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 43 +++++++++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 2 +-
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/EnumUIDefinition.java
| 1 +
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java
| 1 +
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
| 10 ++
5 files changed, 52 insertions(+), 5 deletions(-)
diffs (142 lines):
diff -r 315eeeb8e204 -r 1d1c5fb4c601
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 11 12:45:32 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Wed May 11 13:34:39 2011 +0200
@@ -149,6 +149,10 @@
} catch (JSONException e) {
throw new OBException("Error while parsing content", e);
}
+ List<String> visibleProperties = null;
+ if (jsContent.has("_visibleProperties")) {
+ visibleProperties =
convertJSONArray(jsContent.getJSONArray("_visibleProperties"));
+ }
// create the row from the json content then
if (row == null) {
final JsonToDataConverter fromJsonConverter =
OBProvider.getInstance().get(
@@ -201,7 +205,8 @@
// relevant additional information)
long t5 = System.currentTimeMillis();
computeColumnValues(mode, tab, allColumns, columnValues, parentRecord,
parentId,
- changedColumn, jsContent, changeEventCols, calloutsToCall,
lastfieldChanged);
+ changedColumn, jsContent, changeEventCols, calloutsToCall,
lastfieldChanged,
+ visibleProperties);
// Execution of callouts
long t6 = System.currentTimeMillis();
@@ -246,6 +251,18 @@
return null;
}
+ private List<String> convertJSONArray(JSONArray jsonArray) {
+ List<String> visibleProperties = new ArrayList<String>();
+ for (int i = 0; i < jsonArray.length(); i++) {
+ try {
+ visibleProperties.add(jsonArray.getString(i));
+ } catch (JSONException e) {
+ throw new OBException("Error while reading the visible properties JSON
array");
+ }
+ }
+ return visibleProperties;
+ }
+
private List<JSONObject> attachmentForRows(Tab tab, String rowId, String[]
multipleRowIds) {
String tableId = (String) DalUtil.getId(tab.getTable());
List<JSONObject> attachmentList = new ArrayList<JSONObject>();
@@ -378,7 +395,7 @@
private void computeColumnValues(String mode, Tab tab, List<String>
allColumns,
Map<String, JSONObject> columnValues, BaseOBObject parentRecord, String
parentId,
String changedColumn, JSONObject jsContent, List<String> changeEventCols,
- List<String> calloutsToCall, List<String> lastfieldChanged) {
+ List<String> calloutsToCall, List<String> lastfieldChanged, List<String>
visibleProperties) {
boolean forceComboReload = (mode.equals("CHANGE") && changedColumn ==
null);
if (mode.equals("CHANGE") && changedColumn != null) {
RequestContext.get().setRequestParameter("donotaddcurrentelement",
"true");
@@ -411,7 +428,16 @@
value = uiDef.getFieldProperties(field, true);
} else {
// Else, the default is used
- value = uiDef.getFieldProperties(field, false);
+ if (visibleProperties != null && !field.getColumn().isMandatory()
+ && !visibleProperties.contains("inp" +
Sqlc.TransformaNombreColumna(col))) {
+ // 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
+ value = uiDef.getFieldPropertiesWithoutCombo(field, false);
+ } else {
+ value = uiDef.getFieldProperties(field, false);
+ }
}
} else if (mode.equals("EDIT")
|| (mode.equals("CHANGE") && (forceComboReload || changeEventCols
@@ -419,7 +445,16 @@
// On EDIT mode, the values are computed through the UIDefinition
(the values have been
// previously set in the RequestContext)
// This is also done this way on CHANGE mode where a combo reload is
needed
- value = uiDef.getFieldProperties(field, true);
+ if (visibleProperties != null
+ && !visibleProperties.contains("inp" +
Sqlc.TransformaNombreColumna(col))) {
+ // 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
+ uiDef.getFieldPropertiesWithoutCombo(field, true);
+ } else {
+ value = uiDef.getFieldProperties(field, true);
+ }
} else if (mode.equals("CHANGE") || mode.equals("SETSESSION")) {
// On CHANGE and SETSESSION mode, the values are read from the
request
JSONObject jsCol = new JSONObject();
diff -r 315eeeb8e204 -r 1d1c5fb4c601
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Wed May 11 12:45:32 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Wed May 11 13:34:39 2011 +0200
@@ -479,7 +479,7 @@
// only put the visible field names in the call
for (i = 0; i < this.getFields().length; i++) {
if (this.getFields()[i].inpColumnName) {
- fldNames.push(this.getFields()[i].name)
+ fldNames.push(this.getFields()[i].inpColumnName);
}
}
allProperties._visibleProperties = fldNames;
diff -r 315eeeb8e204 -r 1d1c5fb4c601
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/EnumUIDefinition.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/EnumUIDefinition.java
Wed May 11 12:45:32 2011 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/EnumUIDefinition.java
Wed May 11 13:34:39 2011 +0200
@@ -68,6 +68,7 @@
}
}
+ @Override
public String getFieldPropertiesWithoutCombo(Field field, boolean
getValueFromSession) {
return super.getFieldProperties(field, getValueFromSession);
}
diff -r 315eeeb8e204 -r 1d1c5fb4c601
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java
Wed May 11 12:45:32 2011 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java
Wed May 11 13:34:39 2011 +0200
@@ -55,6 +55,7 @@
}
}
+ @Override
public String getFieldPropertiesWithoutCombo(Field field, boolean
getValueFromSession) {
return super.getFieldProperties(field, getValueFromSession);
}
diff -r 315eeeb8e204 -r 1d1c5fb4c601
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
Wed May 11 12:45:32 2011 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
Wed May 11 13:34:39 2011 +0200
@@ -221,6 +221,16 @@
}
/**
+ * It returns the same as getFieldProperties except in the case of combo
UIDefinitions. In combo
+ * UI definitions, a call to the super will be done, but the combo
computation itself will not be
+ * done (so only the default value, or the current request value, will be
considered).
+ *
+ */
+ public String getFieldPropertiesWithoutCombo(Field field, boolean
getValueFromSession) {
+ return getFieldProperties(field, getValueFromSession);
+ }
+
+ /**
* Returns alignment in grid view. In case it returns null, default
alignment for actual data type
* is used.
*
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits