Fixes issue 20728: IDs shown only for fields that without referencial integrity
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 19 Sep 2012 17:49:12 +0200
changeset 17984 7e0c66407ed1
parent 17983 7d048ad0b76f
child 17985 a15fcd799ebf
Fixes issue 20728: IDs shown only for fields that without referencial integrity

Prior to this fix, if one foreign key field contained and non existent id, all foreign key fields showed the id instead of the displayed column of the referenced field. Now, only the fields that contain nonexistent id will show the id.
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 Sep 19 17:38:29 2012 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Wed Sep 19 17:49:12 2012 +0200
@@ -632,8 +632,7 @@
           }
         }
       } catch (Exception e) {
-        throw new OBException(
-            "Couldn't get data for column " + field.getColumn().getDBColumnName(), e);
+        log.error("Couldn't get data for column " + field.getColumn().getDBColumnName(), e);
       }
     }
 
@@ -1019,27 +1018,32 @@
       currentValue = obj.get(prop.getName());
     }
 
-    if (currentValue != null && !currentValue.toString().equals("null")) {
-      if (currentValue instanceof BaseOBObject) {
-        if (prop.getReferencedProperty() != null) {
-          currentValue = ((BaseOBObject) currentValue).get(prop.getReferencedProperty().getName());
+    try {
+      if (currentValue != null && !currentValue.toString().equals("null")) {
+        if (currentValue instanceof BaseOBObject) {
+          if (prop.getReferencedProperty() != null) {
+            currentValue = ((BaseOBObject) currentValue)
+                .get(prop.getReferencedProperty().getName());
+          } else {
+            currentValue = ((BaseOBObject) currentValue).getId();
+          }
         } else {
-          currentValue = ((BaseOBObject) currentValue).getId();
+          currentValue = UIDefinitionController.getInstance().getUIDefinition(prop.getColumnId())
+              .convertToClassicString(currentValue);
         }
-      } else {
-        currentValue = UIDefinitionController.getInstance().getUIDefinition(prop.getColumnId())
-            .convertToClassicString(currentValue);
+        if (currentValue != null && currentValue.equals("null")) {
+          currentValue = null;
+        }
+        if (currentValue == null) {
+          RequestContext.get().setRequestParameter(
+              "inp" + Sqlc.TransformaNombreColumna(columnName), null);
+        } else {
+          RequestContext.get().setRequestParameter(
+              "inp" + Sqlc.TransformaNombreColumna(columnName), currentValue.toString());
+        }
       }
-      if (currentValue != null && currentValue.equals("null")) {
-        currentValue = null;
-      }
-      if (currentValue == null) {
-        RequestContext.get().setRequestParameter("inp" + Sqlc.TransformaNombreColumna(columnName),
-            null);
-      } else {
-        RequestContext.get().setRequestParameter("inp" + Sqlc.TransformaNombreColumna(columnName),
-            currentValue.toString());
-      }
+    } catch (Exception e) {
+      log.error("Couldn't get the value for column " + columnName);
     }
   }