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

Log:
Completing gadget addition from the directory page.

Modified:
   trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp
   trunk/mashup/java/modules/dashboard/directory.jsp

Modified: trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp?rev=17941&r1=17940&r2=17941&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp     (original)
+++ trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp     Wed Jun  4 
21:07:09 2008
@@ -23,7 +23,6 @@
     String thisPage = request.getContextPath() + "/ajax_add_gadget.jsp";
 %>
 
-<!--Required to keep a user logged in if 'Remember Me' option is selected-->
 <%@ include file="login_validator.jsp" %>
 
 <%
@@ -46,7 +45,12 @@
             if (method != null && method.equals("delete")) {
                 // todo Add deletion code
             } else {
-                if (userRegistry.get(gadgetPath) == null) {
+                try {
+                    gadgetList = userRegistry.get(gadgetPath);
+                    ArrayList gadgetUrls = (ArrayList) 
gadgetList.getPropertyValues("GADGET_LIST");
+                    gadgetUrls.add(gadgetUrl);
+                    gadgetList.setProperty("GADGET_LIST", gadgetUrls);
+                } catch (RegistryException e) {
                     // Creating the resource
                     gadgetList = new ResourceImpl();
                     gadgetList.setDescription(
@@ -54,11 +58,6 @@
                     ArrayList gadgetUrls = new ArrayList();
                     gadgetUrls.add(gadgetUrl);
                     gadgetList.setProperty("GADGET_LIST", gadgetUrls);
-                } else {
-                    gadgetList = userRegistry.get(gadgetPath);
-                    ArrayList gadgetUrls = (ArrayList) 
gadgetList.getPropertyValues("GADGET_LIST");
-                    gadgetUrls.add(gadgetUrl);
-                    gadgetList.setProperty("GADGET_LIST", gadgetUrls);
                 }
 
                 try {
@@ -75,10 +74,10 @@
     }
 
     if (!success) { %>
-<div class="error">Error! <%=reason%>
+Error! <%=reason%>
 </div>
 <% } else {
 %>
-<div class="success">success</div>
+Done. The gadget will appear in your dashboard after a refresh
 <%
     }%>
\ No newline at end of file

Modified: trunk/mashup/java/modules/dashboard/directory.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/directory.jsp?rev=17941&r1=17940&r2=17941&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/directory.jsp   (original)
+++ trunk/mashup/java/modules/dashboard/directory.jsp   Wed Jun  4 21:07:09 2008
@@ -49,16 +49,38 @@
 <head>
     <title><%= bundle.getString("main.title")%> - Dashboard :: Add 
Gadgets</title>
     <link rel="stylesheet" href="css/gadgets.css">
-
+    <script type="text/javascript" language="JavaScript" 
src="javascript/prototype.js"></script>
     <script type="text/javascript" language="JavaScript">
+        // Stores a given gadget URL in the registry, which will be displayed 
after the next dashboard refresh.
         function addGadget(url) {
-            alert(url);
+            new Ajax.Request("ajax_add_gadget.jsp?", {
+                method: "post",
+                parameters: {
+                    "gadgetUrl" : url
+                },
+                onSuccess: function (transport) {
+                    alert(transport.responseText.replace(/^\s+|\s+$/g, ''));
+                },
+                onFailure: function (transport) {
+                    alert(transport.responseText.replace(/^\s+|\s+$/g, ''));
+                }
+            });
         }
     </script>
 </head>
 <body>
-<h2><%= bundle.getString("main.title")%> - Add Gadgets to the Dashboard 
[<%=currentUser%>]</h2>
+<h2><%= bundle.getString("main.title")%> - Customize <%=RegistryUtils
+        .getFullName(request, currentUser)%>s Dashboard</h2>
+
+<h4>You can add Google Gadgets from remote servers or select from Mashups 
available in this
+    server.</h4>
 
+<div id="remote-gadgets">
+    <p><label>Gadget URL </label><input type="text" id="txtGadgetUrl" 
size="80"/><input
+            type="button" 
onclick="addGadget(document.getElementById('txtGadgetUrl').value);"
+            value="Add it now"/></p>
+</div>
+<hr/>
 <div id="local-gadgets">
 
     <%
@@ -82,10 +104,13 @@
     <div class="directory-entry">
         <div class="gadget">
             <%=result.getName()%>
-            <div><input type="button" onclick="addGadget('<%=gadgetUrl%>');" 
value="Add it now"/></div>
+            <div><input type="button" onclick="addGadget('<%=gadgetUrl%>');" 
value="Add it now"/>
+            </div>
         </div>
         <div class="author">
-            <p>By <%=RegistryUtils.getFullName(request, 
result.getAuthor())%></p>
+            <p>By <%=RegistryUtils.getFullName(request, result.getAuthor())%>
+            </p>
+
             <p><a href="<%=gadgetUrl%>">View Source</a></p>
         </div>
         <div class="info">

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to