details: https://code.openbravo.com/erp/devel/pi/rev/cd1ddf017185
changeset: 27144:cd1ddf017185
user: Carlos Aristu <carlos.aristu <at> openbravo.com>
date: Wed Jul 22 17:02:50 2015 +0200
summary: Fixes issue 30403: selectors not working in grid view when display field is set
When setting the display field for a selector with FKSelectorUIDefinition as its UI Definition class, if the display field was referencing to a property of the main entity of the selector, the display field name returned as part of the gridProps in the view definition was 'entity'.
The _extraProperties in the datasource used by the selector does not contain the entity name if they are referencing to the main entity. That is the root of the problem: when trying to set the selected value of the selector picklist in grid view, the display field name was never found as we were using 'entity' instead of looking directly for 'property'.
This problem does not affect when setting as display field a field that references a property which does not belong to the main entity of the selector.
To solve this problem, now in FKSelectorUIDefinition we return 'property' as the display field name instead of 'entity' when the property belongs to the main entity.
diffstat:
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/FKSelectorUIDefinition.java | 14 +---------
1 files changed, 1 insertions(+), 13 deletions(-)
diffs (28 lines):
diff -r dcf8b6e81b7b -r cd1ddf017185 modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/FKSelectorUIDefinition.java
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/FKSelectorUIDefinition.java Wed Jul 22 11:02:34 2015 +0200
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/FKSelectorUIDefinition.java Wed Jul 22 17:02:50 2015 +0200
@@ -106,23 +106,11 @@
String displayFieldName = JsonConstants.IDENTIFIER;
if (displayField != null && displayField.getProperty() != null) {
displayFieldName = displayField.getProperty();
+ return displayFieldName.replace(".", DalUtil.FIELDSEPARATOR);
} else {
// fallback to the default
return null;
}
-
- if (!prop.getReferencedProperty().getEntity().hasProperty(getFirstProperty(displayFieldName))) {
- // If the first property of the display field name does not belong to the referenced entity,
- // return the displayFieldName
- // Otherwise trying to append the displayFieldName to the referenced property would later
- // result in an error
- return displayFieldName.replace(".", DalUtil.FIELDSEPARATOR);
- } else {
- final String result = (prop.getName() + DalUtil.FIELDSEPARATOR + displayFieldName).replace(
- ".", DalUtil.FIELDSEPARATOR);
- return result;
- }
-
}
private String getFirstProperty(String displayFieldName) {