[OBKMO] Use getOneInstance method to get only one active URL
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Thu, 03 Mar 2011 18:04:40 +0100
changeset 11003 c3dea134444b
parent 11002 3a41ea6852df
child 11004 e0cec10b5839
[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 17:53:57 2011 +0100
+++ b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/URLWidgetProvider.java	Thu Mar 03 18:04:40 2011 +0100
@@ -22,6 +22,8 @@
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.base.exception.OBException;
+import org.openbravo.dal.service.OBDao;
+import org.openbravo.dal.service.OBDao.Constraint;
 
 /**
  * Responsible for creating the URL Widgets.
@@ -51,8 +53,10 @@
       final JSONObject jsonObject = super.getWidgetClassDefinition();
       final JSONObject parameters = new JSONObject();
       jsonObject.put(WidgetProvider.PARAMETERS, parameters);
-      if (!getWidgetClass().getOBKMOWidgetURLList().isEmpty()) {
-        parameters.put(SRC, getWidgetClass().getOBKMOWidgetURLList().get(0).getURL());
+      WidgetURL widgetURL = OBDao.getOneInstance(WidgetURL.class, new Constraint(
+          WidgetURL.PROPERTY_WIDGETCLASS, getWidgetClass()));
+      if (widgetURL != null) {
+        parameters.put(SRC, widgetURL.getURL());
       } else {
         log.warn("URLWidget does not have a URL defined.");
         parameters.put(SRC, "");