[mashup-dev] svn commit r17942 - trunk/mashup/java/modules/dashboard

tyrell at wso2.com tyrell at wso2.com
Wed Jun 4 21:35:11 PDT 2008


Author: tyrell
Date: Wed Jun  4 21:35:11 2008
New Revision: 17942
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17942

Log:
Loading widgets using the URLs stored in the users registry.

Modified:
   trunk/mashup/java/modules/dashboard/index.jsp

Modified: trunk/mashup/java/modules/dashboard/index.jsp
URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/index.jsp?rev=17942&r1=17941&r2=17942&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/index.jsp	(original)
+++ trunk/mashup/java/modules/dashboard/index.jsp	Wed Jun  4 21:35:11 2008
@@ -22,6 +22,10 @@
 <%@ page import="org.apache.axis2.context.ConfigurationContext" %>
 <%@ page import="org.wso2.mashup.utils.MashupUtils" %>
 <%@ page import="org.wso2.mashup.MashupConstants" %>
+<%@ page import="java.util.ArrayList" %>
+<%@ page import="org.wso2.registry.exceptions.RegistryException" %>
+<%@ page import="org.wso2.registry.Resource" %>
+<%@ page import="java.util.Iterator" %>
 
 <%
     String thisPage = request.getContextPath() + "/index.jsp";
@@ -63,9 +67,33 @@
         };
 
         wso2.dashboard.gadgetSpecUrls = [
-            'http://www.google.com/ig/modules/horoscope.xml',
-            'http://www.italiagadget.net/tarocchi/witches.xml',
-            'http://www.labpixies.com/campaigns/weather/weather.xml'
+            <%
+          // Retrieving the users stored gadgets from the registry location
+          String gadgetPath = MashupConstants.USERS_PATH + "/" + currentUser + "/gadgets";
+          Resource gadgetList;
+          ArrayList gadgetUrls = null;
+          try {
+                   gadgetList = userRegistry.get(gadgetPath);
+                   gadgetUrls = (ArrayList) gadgetList.getPropertyValues("GADGET_LIST");
+
+                   Iterator urls = gadgetUrls.iterator();
+                   boolean firstUrl = true;
+                   while(urls.hasNext()){
+                   if(firstUrl){
+            %>
+            '<%=(String)urls.next()%>'
+            <%
+            firstUrl = false;
+            }else{
+                 %>
+            ,'<%=(String)urls.next()%>'
+            <%
+                 }
+                    }
+                } catch (RegistryException e) {
+
+                }
+        %>
         ];
 
 
@@ -100,15 +128,27 @@
 <h2><%= bundle.getString("main.title")%> - Dashboard [<%=currentUser%>]</h2>
 
 <div id="widgets">
-    <div id="widget_col_0">
-        <div id="gadget-chrome-0" class="gadgets-gadget-chrome"></div>
-    </div>
-    <div id="widget_col_1">
-        <div id="gadget-chrome-1" class="gadgets-gadget-chrome"></div>
-    </div>
-    <div id="widget_col_2">
-        <div id="gadget-chrome-2" class="gadgets-gadget-chrome"></div>
+    <%
+        int widgetCount = 0;
+        if (gadgetUrls != null) {
+            widgetCount = gadgetUrls.size();
+        }
+
+        int currentColumnId = 0;
+
+        for (int x = 0; x < widgetCount; x++) {
+            if (currentColumnId > 2) {
+                currentColumnId = 0;
+            }
+    %>
+    <div id="widget_col_<%=currentColumnId%>">
+        <div id="gadget-chrome-<%=x%>" class="gadgets-gadget-chrome"></div>
     </div>
+    <%
+            currentColumnId++;
+        }
+
+    %>
 </div>
 </body>
 </html>



More information about the Mashup-dev mailing list