You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by dd...@apache.org on 2006/12/14 00:58:09 UTC
svn commit: r486896 - in /portals/pluto/trunk:
pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
Author: ddewolf
Date: Wed Dec 13 15:58:08 2006
New Revision: 486896
URL: http://svn.apache.org/viewvc?view=rev&rev=486896
Log:
Moving towards remove portlet functionality in the admin portlet
Modified:
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java?view=diff&rev=486896&r1=486895&r2=486896
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java Wed Dec 13 15:58:08 2006
@@ -20,10 +20,17 @@
import org.apache.pluto.driver.config.DriverConfiguration;
import org.apache.pluto.driver.AttributeKeys;
import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.services.portal.PortletWindowConfig;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
-import java.util.Map;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.io.IOException;
public class PageAdminPortlet extends GenericPlutoPortlet {
@@ -38,7 +45,7 @@
public void processAction(ActionRequest request, ActionResponse response) {
String page = request.getParameter("page");
String applicationId = request.getParameter("applications");
- String portletId = request.getParameter("portlets");
+ String portletId = request.getParameter("availablePortlets");
LOG.info("Request: Add [applicationId="+applicationId+":portletId="+portletId+"] to page '"+page+"'");
@@ -51,7 +58,10 @@
response.setRenderParameter("portlets", portletId);
}
-
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
+ request.setAttribute("availablePages", getAvailablePages());
+ super.doView(request, response);
+ }
public String getViewPage() {
return VIEW_PAGE;
@@ -64,4 +74,90 @@
public String getHelpPage() {
return HELP_PAGE;
}
+
+ public Collection getAvailablePages() {
+ DriverConfiguration configuration =
+ (DriverConfiguration) getPortletContext().getAttribute(AttributeKeys.DRIVER_CONFIG);
+
+ ArrayList list = new ArrayList();
+ Iterator it = configuration.getPages().iterator();
+ while(it.hasNext()) {
+ PageConfig config = (PageConfig)it.next();
+ ArrayList portlets = new ArrayList();
+ Iterator pids = config.getPortletIds().iterator();
+ while(pids.hasNext()) {
+ String pid = pids.next().toString();
+ String name = PortletWindowConfig.parsePortletName(pid);
+ portlets.add(new Placement(pid, name));
+ }
+ list.add(new Page(config.getName(), config.getName(), portlets));
+ }
+
+ return list;
+ }
+
+ public class Page {
+ private String id;
+ private String name;
+ private Collection portlets;
+
+
+ public Page(String pageId, String pageName, Collection portlets) {
+ this.id = pageId;
+ this.name = pageName;
+ this.portlets = portlets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Collection getPortlets() {
+ return portlets;
+ }
+
+ public void setPortlets(Collection portlets) {
+ this.portlets = portlets;
+ }
+ }
+
+ public class Placement {
+ private String id;
+ private String portletName;
+
+ public Placement(String id, String portletName) {
+ this.id = id;
+ this.portletName = portletName;
+ }
+
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPortletName() {
+ return portletName;
+ }
+
+ public void setPortletName(String portletName) {
+ this.portletName = portletName;
+ }
+ }
+
}
Modified: portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp?view=diff&rev=486896&r1=486895&r2=486896
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp (original)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp Wed Dec 13 15:58:08 2006
@@ -19,14 +19,53 @@
<portlet:actionURL var="formActionUrl"/>
<form name="adminForm" action="<c:out value="${formActionUrl}"/>" method="POST">
+<script type="text/javascript">
+
+
+</script>
+
<div>
<h2>Portal Pages</h2>
<p>
- <select name="page">
+ <script type="text/javascript">
+ var placedPortlets = new Array();
+ <c:forEach items="${availablePages}" var="page">
+ placedPortlets['<c:out value="${page.id}"/>'] = new Array();
+ var i = 0;
+ <c:forEach items="${page.portlets}" var="portlet">
+ placedPortlets['<c:out value="${page.id}"/>'][i] = new Array();
+ placedPortlets['<c:out value="${page.id}"/>'][i][0] = '<c:out value="${portlet.id}"/>';
+ placedPortlets['<c:out value="${page.id}"/>'][i++][1] = '<c:out value="${portlet.portletName}"/>';
+ </c:forEach>
+ </c:forEach>
+
+ function doSwitchPage(select) {
+ var placePortletsSelect = document.forms['adminForm'].elements['placedPortlets'];
+ for(var i=0;i<placePortletsSelect.options.length;i++) {
+ placePortletsSelect.options[i] = null;
+ }
+
+
+ for(var i=0;i<placedPortlets[select.value].length;i++) {
+ placePortletsSelect[i] = new Option(placedPortlets[select.value][i][1], placedPortlets[select.value][i][0]);
+ }
+ }
+ </script>
+
+
+
+
+
+ <select name="page" onChange="doSwitchPage(this)">
+ <option>Select. . .</option>
<c:forEach items="${driverConfig.pages}" var="page">
<option value="<c:out value="${page.name}"/>"><c:out value="${page.name}"/></option>
</c:forEach>
</select>
+
+ <select name="placedPortlets" size="5">
+
+ </select>
</p>
</div>
@@ -47,9 +86,12 @@
</c:forEach>
function doSwitch(select) {
- var portletsSelectBox = document.forms['adminForm'].elements['portlets'];
+ var portletsSelectBox = document.forms['adminForm'].elements['availablePortlets'];
+ for(i = 0; i< portletsSelectBox.options.length;i++) {
+ portletsSelectBox.options[i] = null;
+ }
if (select.value == '-') {
- document.forms['adminForm'].elements['portlets'].disabled = true;
+ document.forms['adminForm'].elements['availablePortlets'].disabled = true;
} else {
portletsSelectBox.disabled = false;
var pList = portlets[select.value];
@@ -65,14 +107,14 @@
}
</script>
- <select name="applications" onChange="doSwitch(this)">
- <option value='-'>Select. . .</option>
- <c:forEach items="${portletContainer.optionalContainerServices.portletRegistryService.registeredPortletApplications}" var="app">
- <option value="<c:out value="${app.applicationId}"/>"><c:out value="${app.applicationName}"/></option>
- </c:forEach>
+ <select name="applications" onChange="doSwitch(this)">
+ <option value='-'>Select. . .</option>
+ <c:forEach items="${portletContainer.optionalContainerServices.portletRegistryService.registeredPortletApplications}" var="app">
+ <option value="<c:out value="${app.applicationId}"/>"><c:out value="${app.applicationName}"/></option>
+ </c:forEach>
</select>
- <select name="portlets" disabled="true" onChange='doSwitchButton(this)'>
+ <select name="availablePortlets" disabled="true" onChange='doSwitchButton(this)'>
</select>