[OBKMO] Use getOneInstance method to get only one active URL
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Thu, 03 Mar 2011 18:08:24 +0100
changeset 11004 e0cec10b5839
parent 11003 c3dea134444b
child 11005 3637e5ba01b9
[OBKMO] Use getOneInstance method to get only one active URL
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/URLWidgetProvider.java
--- a/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/URLWidgetProvider.java	Thu Mar 03 18:04:40 2011 +0100
+++ b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/URLWidgetProvider.java	Thu Mar 03 18:08:24 2011 +0100
@@ -53,7 +53,7 @@
       final JSONObject jsonObject = super.getWidgetClassDefinition();
       final JSONObject parameters = new JSONObject();
       jsonObject.put(WidgetProvider.PARAMETERS, parameters);
-      WidgetURL widgetURL = OBDao.getOneInstance(WidgetURL.class, new Constraint(
+      final WidgetURL widgetURL = OBDao.getOneInstance(WidgetURL.class, new Constraint(
           WidgetURL.PROPERTY_WIDGETCLASS, getWidgetClass()));
       if (widgetURL != null) {
         parameters.put(SRC, widgetURL.getURL());
@@ -76,11 +76,12 @@
       final JSONObject jsonObject = new JSONObject();
       addDefaultWidgetProperties(jsonObject, widgetInstance);
       final JSONObject parameters = jsonObject.getJSONObject(WidgetProvider.PARAMETERS);
-      if (widgetInstance.getWidgetClass().getOBKMOWidgetURLList().isEmpty()) {
+      final WidgetURL widgetURL = OBDao.getOneInstance(WidgetURL.class, new Constraint(
+          WidgetURL.PROPERTY_WIDGETCLASS, getWidgetClass()));
+      if (widgetURL != null) {
+        parameters.put(SRC, widgetURL.getURL());
+      } else {
         log.error("No url widget defined for widget class " + widgetInstance.getWidgetClass());
-      } else {
-        parameters
-            .put(SRC, widgetInstance.getWidgetClass().getOBKMOWidgetURLList().get(0).getURL());
       }
       return jsonObject;
     } catch (Exception e) {