[gatein-commits] gatein SVN: r4646 - in portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main: webapp/groovy/gadget/webui/component and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 12 22:58:34 EDT 2010


Author: kien_nguyen
Date: 2010-10-12 22:58:33 -0400 (Tue, 12 Oct 2010)
New Revision: 4646

Modified:
   portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java
   portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl
Log:
GTNPORTAL-1497 Misleading error message when Gadget does not exist

Modified: portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java	2010-10-13 01:41:23 UTC (rev 4645)
+++ portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/java/org/exoplatform/gadget/webui/component/UIGadgetPortlet.java	2010-10-13 02:58:33 UTC (rev 4646)
@@ -75,6 +75,14 @@
             {
                return GadgetUtil.reproduceUrl(gadget.getUrl(), gadget.isLocal());
             }
+            else 
+            {
+            	if (log.isWarnEnabled())
+            	{
+            	   log.warn("The local gadget '" + gadgetName + "' was not found, nothing rendered");
+            	}
+            	return null;
+            }
          }
          catch (Exception e)
          {
@@ -94,6 +102,11 @@
          uiApplication.addMessage(new ApplicationMessage("UIGadgetPortlet.msg.url-invalid", null));
       }
 
+      return getMetadata(url);
+   }
+   
+   public String getMetadata(String url)
+   {
       String metadata_ = GadgetUtil.fetchGagdetMetadata(url);
       try
       {

Modified: portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl
===================================================================
--- portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl	2010-10-13 01:41:23 UTC (rev 4645)
+++ portal/branches/branch-GTNPORTAL-1537/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl	2010-10-13 02:58:33 UTC (rev 4646)
@@ -5,19 +5,23 @@
 	import org.exoplatform.webui.application.portlet.PortletRequestContext;
 	
 	def hostName = GadgetUtil.getRelGadgetServerUrl();
-  def rcontext = _ctx.getRequestContext() ;
-  def windowId = rcontext.getWindowId();
-  def id = uicomponent.getId() + "-" + windowId ;
-  def url = uicomponent.getParent().getUrl();
-  def metadata = uicomponent.getParent().getMetadata();
-  def userPref = null;//uicomponent.getUserPref() ;
-  JavascriptManager jsmanager = rcontext.getJavascriptManager();
-	jsmanager.importJavascript("eXo.gadget.UIGadget") ;
-	jsmanager.addCustomizedOnLoadScript("eXo.gadget.UIGadget.createGadget('$url','$id', $metadata, $userPref, 'canvas', '$hostName');") ;
-	java.util.Map<String, String> metadataMap = GadgetUtil.getMapMetadata(url) ;
-	String height = "auto" ;
-	if(metadataMap.containsKey("height")  && Integer.parseInt(metadataMap.get("height")) > 0) 
-		height = (Integer.parseInt(metadataMap.get("height")) + 10) + "px" ;
+	def rcontext = _ctx.getRequestContext() ;
+	def windowId = rcontext.getWindowId();
+	def id = uicomponent.getId() + "-" + windowId ;
+	def url = uicomponent.getParent().getUrl();
+	def height = "auto" ;
+	
+	if(url != null) {
+  	def metadata = uicomponent.getParent().getMetadata(url);
+  	def userPref = null;
+  	JavascriptManager jsmanager = rcontext.getJavascriptManager();
+  	jsmanager.importJavascript("eXo.gadget.UIGadget") ;
+  	jsmanager.addCustomizedOnLoadScript("eXo.gadget.UIGadget.createGadget('$url','$id', $metadata, $userPref, 'canvas', '$hostName');") ;
+  	java.util.Map<String, String> metadataMap = GadgetUtil.getMapMetadata(url) ;
+	
+  	if(metadataMap.containsKey("height")  && Integer.parseInt(metadataMap.get("height")) > 0) 
+  		height = (Integer.parseInt(metadataMap.get("height")) + 10) + "px" ;
+  }
 %>
 
 <div class="UIGadgetViewMode" id="$id" style="height: <%=height%>;"></div>



More information about the gatein-commits mailing list