portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r888524 - /portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Tue, 08 Dec 2009 19:04:37 GMT
Author: woonsan
Date: Tue Dec  8 19:04:37 2009
New Revision: 888524

URL: http://svn.apache.org/viewvc?rev=888524&view=rev
Log:
JS2-1087: Adding rest invocation to add portlet.
TODO: Move "addPortletToLeastUsedColumn" method to layout component. How to avoid refreshing
after portlet addition?

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp?rev=888524&r1=888523&r2=888524&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Tue Dec  8 19:04:37 2009
@@ -35,6 +35,7 @@
 <c:if test="${empty portalContextPath}">
   <c:set var="portalContextPath" value="/"/>
 </c:if>
+<c:set var="portalServletPath" value="${requestContext.request.servletPath}"/>
 
 <table style="border-collapse: collapse;  width: 100%; margin-top: 0px; margin-bottom:
0px; float: left;">
     <tr>
@@ -240,9 +241,8 @@
 
             <c:choose>
 	            <c:when test="${editAccess}">
-	                var actionURL = "<portlet:actionURL/>";
-	                var addActionURL = actionURL + (actionURL.indexOf('?') == -1 ? "?portletAdd="
: "&portletAdd=") + def.uniqueName;
-	                clone.all("a").item(1).set("href", addActionURL);
+	                Y.Node.getDOMNode(clone.all("a").item(1)).setAttribute("portletUniqueName",
def.uniqueName);
+	                clone.all("a").item(1).on("click", addPortlet);
 	            </c:when>
 	            <c:otherwise>
 	                clone.all("a").item(1).remove();
@@ -288,6 +288,30 @@
 
         e.halt();
     };
+
+    var onAddPortletComplete = function(id, o, args) {
+        if (o.status == 200 && o.readyState == 4) {
+            location.reload();
+        }
+    };
+    
+    var addPortlet = function(e) {
+        var a = Y.Node.getDOMNode(e.target);
+        var portletUniqueName = a.getAttribute("portletUniqueName");
+
+        if (portletUniqueName) {
+            var re = new RegExp("\\" + "${portalServletPath}" + "(\\/|$)");
+            var uri = location.href.replace(re, "/services/").replace(/#$/, "");
+            Y.on('io:complete', onAddPortletComplete, this, []);
+            var config = {
+                    method: "POST",
+                    data: "type=portlet&name=" + portletUniqueName 
+                };
+            var request = Y.io(uri, config);
+        }
+            
+        e.halt();
+    };
     
     Y.on("click", switchTab, "#<portlet:namespace/>portletsTabAction");
     Y.on("click", switchTab, "#<portlet:namespace/>layoutsTabAction");



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message