Fixed issue 19321. Session variables will be computed correctly in case the Parent Id is 'null' (as a string)
authorAntonio Moreno <antonio.moreno@openbravo.com>
Mon, 13 Feb 2012 11:30:11 +0100
changeset 15478 86ac4bc5c360
parent 15477 a03579ebb79e
child 15479 3082e66a5d16
Fixed issue 19321. Session variables will be computed correctly in case the Parent Id is 'null' (as a string)
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	Sun Feb 12 20:43:46 2012 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Mon Feb 13 11:30:11 2012 +0100
@@ -113,17 +113,17 @@
       // - EDIT: used when the user opens a record in form view
       // - CHANGE: used when the user changes a field which should fire callouts or comboreloads
       // - SETSESSION: used when the user calls a process
-      String mode = (String) parameters.get("MODE");
+      String mode = readParameter(parameters, "MODE");
       // ID of the parent record
-      String parentId = (String) parameters.get("PARENT_ID");
+      String parentId = readParameter(parameters, "PARENT_ID");
       // The ID of the tab
-      String tabId = (String) parameters.get("TAB_ID");
+      String tabId = readParameter(parameters, "TAB_ID");
       // The ID of the record. Only relevant on EDIT, CHANGE and SETSESSION modes
-      String rowId = (String) parameters.get("ROW_ID");
+      String rowId = readParameter(parameters, "ROW_ID");
       // The IDs of the selected records in case more than one
       String multipleRowIds[] = (String[]) parameters.get("MULTIPLE_ROW_IDS");
       // The column changed by the user. Only relevant on CHANGE mode
-      String changedColumn = (String) parameters.get("CHANGED_COLUMN");
+      String changedColumn = readParameter(parameters, "CHANGED_COLUMN");
       Tab tab = OBDal.getInstance().get(Tab.class, tabId);
       BaseOBObject row = null;
       BaseOBObject parentRecord = null;
@@ -1559,4 +1559,11 @@
     return cachedStructures.getAuxiliarInputList(tabId);
   }
 
+  private String readParameter(Map<String, Object> parameters, String parameterName) {
+    String paramValue = (String) parameters.get(parameterName);
+    if (paramValue != null && paramValue.equalsIgnoreCase("null")) {
+      paramValue = null;
+    }
+    return paramValue;
+  }
 }