portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r947963 - /portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Tue, 25 May 2010 08:48:08 GMT
Author: woonsan
Date: Tue May 25 08:48:08 2010
New Revision: 947963

URL: http://svn.apache.org/viewvc?rev=947963&view=rev
Log:
JS2-1194: Adding page refresh option when adding a portlet by the metadata value of "jetui.refresh.page.on.add.portle"
of a portlet definition.
When the metadata is true, the toolbox portlet will refresh the page.

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=947963&r1=947962&r2=947963&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 May 25 08:48:08 2010
@@ -412,11 +412,27 @@ YUI().use('jetui-portal', 'io', 'json', 
             var nameNode = clone.one('div');
             var portletDisplayName = def.displayNames[0].value;
             nameNode.setContent(portletDisplayName);
-
+            
+            var refreshOnAdd = false;
+            var metadataFields = def.metadata.fields;
+            if (metadataFields) {
+                for (var j = 0; j < metadataFields.length; j++) {
+                    var field = metadataFields[j];
+                    if (field.name == "jetui.refresh.page.on.add.portlet") {
+                        refreshOnAdd = ("TRUE" == ("" + field.value).toUpperCase());
+                        break;
+                    }
+                }
+            }
+            
             <c:choose>
 	            <c:when test="${editAccess}">
 	                var addLink = clone.one("[name='add']");
-	                Y.Node.getDOMNode(addLink).setAttribute("portletUniqueName", def.uniqueName);
+	                var addLinkNode = Y.Node.getDOMNode(addLink);
+	                addLinkNode.setAttribute("portletUniqueName", def.uniqueName);
+	                if (refreshOnAdd) {
+	                    addLinkNode.setAttribute("refreshOnAdd", "" + refreshOnAdd);
+	                }
 	                addLink.on("click", addPortlet);
 	            </c:when>
 	            <c:otherwise>
@@ -523,6 +539,7 @@ YUI().use('jetui-portal', 'io', 'json', 
         var id = id;
         var data = o.responseText;
         var dataOut = null;
+        var refreshOnAdd = args.complete[0];
 
         try {
             dataOut = Y.JSON.parse(data);
@@ -534,9 +551,9 @@ YUI().use('jetui-portal', 'io', 'json', 
             Y.log("Error: " + e.message);
             return;
         }
-
+        
         var portal = (JETUI_YUI ? JETUI_YUI.getPortalInstance() : null);
-        if (portal) {
+        if (portal && !refreshOnAdd) {
 	        portal.addPortlet(dataOut);
         } else {
             location.href = location.href;
@@ -546,11 +563,13 @@ YUI().use('jetui-portal', 'io', 'json', 
     var addPortlet = function(e) {
         var a = Y.Node.getDOMNode(e.target);
         var portletUniqueName = a.getAttribute("portletUniqueName");
+        var refreshOnAdd = ("true" == a.getAttribute("refreshOnAdd"));
 
         if (portletUniqueName) {
             var uri = "${portalContextPath}/services/pagelayout/fragment/portlet/" + portletUniqueName
+ "/?_type=json";
             var config = {
                     on: { complete: onAddPortletComplete },
+                    arguments: { complete: [ refreshOnAdd ] },
                     method: "POST",
                     headers: { "X-Portal-Path" : "${portalPagePath}" },
                     data: "minrowscol=true"



---------------------------------------------------------------------
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