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: [email protected]
For additional commands, e-mail: [email protected]