details:   https://code.openbravo.com/erp/devel/pi/rev/a3478b127262
changeset: 21504:a3478b127262
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu Nov 28 16:53:57 2013 +0100
summary:   Fixes bug 25218: Session properties are always included in the grid 
ds request

details:   https://code.openbravo.com/erp/devel/pi/rev/c758874d50d4
changeset: 21505:c758874d50d4
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu Nov 28 18:14:17 2013 +0100
summary:   Fixes issue 25215: All buttons are included in the grid datasource 
response

Initially only the buttons with label values were considered required for the 
grid. This was not enough, because there are buttons with docAction that need 
to have their value present when the button is pressed in order to compute its 
combos properly.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
  |  19 +++++++++
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
 |  13 ++++-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
           |  21 ++++++++++
 src/org/openbravo/base/model/Entity.java                                       
                               |  20 +++++++++
 4 files changed, 69 insertions(+), 4 deletions(-)

diffs (142 lines):

diff -r b74b44228aa6 -r c758874d50d4 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
      Thu Nov 28 21:58:59 2013 +0530
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
      Thu Nov 28 18:14:17 2013 +0100
@@ -74,6 +74,7 @@
   private List<String> windowEntities = null;
   private List<OBViewFieldDefinition> fields;
   private List<String> propertiesInButtonFieldDisplayLogic = new 
ArrayList<String>();
+  private List<String> storedInSessionProperties = new ArrayList<String>();
 
   private List<Field> ignoredFields = new ArrayList<Field>();
 
@@ -332,6 +333,20 @@
       }
     }
 
+    // Stores the stored in session properties, even if they are not shown in 
the grid or form view
+    for (Field field : adFields) {
+      if (field.getColumn() == null || !field.isActive() || 
!field.getColumn().isActive()) {
+        continue;
+      }
+      if (field.getColumn().isStoredInSession()) {
+        Property prop = 
entity.getPropertyByColumnName(field.getColumn().getDBColumnName()
+            .toLowerCase(), false);
+        if (prop != null) {
+          storedInSessionProperties.add(prop.getName());
+        }
+      }
+    }
+
     // Add audit info
     if (!auditFields.isEmpty()) {
       final OBViewFieldGroup viewFieldGroup = new OBViewFieldGroup();
@@ -388,6 +403,10 @@
     return fields;
   }
 
+  public List<String> getStoredInSessionProperties() {
+    return storedInSessionProperties;
+  }
+
   public boolean getHasStatusBarFields() {
     return !statusBarFields.isEmpty();
   }
diff -r b74b44228aa6 -r c758874d50d4 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Thu Nov 28 21:58:59 2013 +0530
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Thu Nov 28 18:14:17 2013 +0100
@@ -264,11 +264,9 @@
     }
 
     // Properties related to buttons that have label values
-    List<ButtonField> buttonFields = getViewTab().getButtonFields();
+    List<ButtonField> buttonFields = getViewTab().getAllButtonFields();
     for (ButtonField buttonField : buttonFields) {
-      if (!buttonField.getLabelValues().isEmpty()) {
-        requiredGridProperties.add(buttonField.getPropertyName());
-      }
+      requiredGridProperties.add(buttonField.getPropertyName());
     }
 
     // List of properties that are part of the display logic of the subtabs
@@ -290,6 +288,13 @@
       requiredGridProperties.add(linkToParentPropertyName);
     }
 
+    // Include the Stored in Session properties
+    List<String> storedInSessionProperties = getViewTab().getFieldHandler()
+        .getStoredInSessionProperties();
+    for (String storedInSessionProperty : storedInSessionProperties) {
+      requiredGridProperties.add(storedInSessionProperty);
+    }
+
     return requiredGridProperties;
   }
 
diff -r b74b44228aa6 -r c758874d50d4 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
       Thu Nov 28 21:58:59 2013 +0530
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
       Thu Nov 28 18:14:17 2013 +0100
@@ -87,6 +87,8 @@
   private OBViewTab parentTabComponent;
   private String parentProperty = null;
   private List<ButtonField> buttonFields = null;
+  // Includes also the non displayed buttons
+  private List<ButtonField> allButtonFields = null;
   private List<IconButton> iconButtons = null;
   private boolean buttonSessionLogic;
   private boolean isRootTab;
@@ -204,6 +206,25 @@
     return buttonFields;
   }
 
+  public List<ButtonField> getAllButtonFields() {
+    if (allButtonFields != null) {
+      return allButtonFields;
+    }
+    allButtonFields = new ArrayList<ButtonField>();
+    final List<Field> adFields = new ArrayList<Field>(tab.getADFieldList());
+    Collections.sort(adFields, new FormFieldComparator());
+    for (Field fld : adFields) {
+      if (fld.isActive()) {
+        if (!(ApplicationUtils.isUIButton(fld))) {
+          continue;
+        }
+        ButtonField btn = new ButtonField(fld);
+        allButtonFields.add(btn);
+      }
+    }
+    return allButtonFields;
+  }
+
   public List<IconButton> getIconButtons() {
     if (iconButtons != null) {
       return iconButtons;
diff -r b74b44228aa6 -r c758874d50d4 src/org/openbravo/base/model/Entity.java
--- a/src/org/openbravo/base/model/Entity.java  Thu Nov 28 21:58:59 2013 +0530
+++ b/src/org/openbravo/base/model/Entity.java  Thu Nov 28 18:14:17 2013 +0100
@@ -573,6 +573,26 @@
     return prop;
   }
 
+  /**
+   * Retrieves the property using the columnName. Throws a CheckException if 
no property exists with
+   * that columnName in case checkIsNotNull is true.
+   * 
+   * @param columnName
+   *          the name used to search for the property.
+   * @param checkIsNotNull
+   *          if true, fails if property does not exists in entity, if false, 
returns null in this
+   *          case
+   * @return the found property
+   * @throws CheckException
+   */
+  public Property getPropertyByColumnName(String columnName, boolean 
checkIsNotNull) {
+    final Property prop = propertiesByColumnName.get(columnName);
+    if (checkIsNotNull) {
+      Check.isNotNull(prop, "Property " + columnName + " does not exist for 
entity " + this);
+    }
+    return prop;
+  }
+
   public String getPackageName() {
     final int lastIndexOf = getClassName().lastIndexOf('.');
     return getClassName().substring(0, lastIndexOf);

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to