Author: julien(a)jboss.com
Date: 2007-06-20 18:59:02 -0400 (Wed, 20 Jun 2007)
New Revision: 7491
Added:
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/content/
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
Modified:
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
Log:
implementation of new portlet instance selector that requires one click. still a bit ugly
but more usable
Modified:
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2007-06-20
21:29:53 UTC (rev 7490)
+++
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2007-06-20
22:59:02 UTC (rev 7491)
@@ -37,6 +37,7 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletURL;
+import javax.portlet.PortletRequestDispatcher;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@@ -128,71 +129,25 @@
};
Collections.sort(available_instances, simpleComparator);
- Instance selectedInstance = null;
-
- if (!newContent)
- {
- writer.print("<span class=\"portlet-font\">Portlet instance
associated to this window:</span>");
- }
- else
- {
- writer.print("<span class=\"portlet-font\">Select a portlet
instance to associate to this window:</span>");
- }
-
//
- writer.print("<form id=\"portlet_selection_form\"
action=\"");
- writer.print(actionURL);
- writer.print("\" method=\"post\">\n");
- writer.println("<select
name=\"content.uri\"size=\"20\">\n");
+ Instance selectedInstance = null;
for (int i = 0; i < available_instances.size(); i++)
{
Instance instance = (Instance)available_instances.get(i);
-
- //
- writer.print("<option value=\"");
- writer.print(instance.getId());
- writer.print("\"");
-
- //
if (instance.getId().equals(selectedURI))
{
selectedInstance = instance;
- writer.print(" selected=\"selected\"");
}
-
- //
- writer.print(">");
- writer.print(instance.getId());
- writer.println("</option>\n");
}
- writer.println("</select><br />");
- String buttonText = (newContent) ? "Select" : "Update";
- writer.println("<input type=\"submit\"
name=\"content.action.select\" value=\"" + buttonText + "\"
class=\"portlet-form-button\"/>");
- writer.print("</form>");
+ //
+ req.setAttribute("INSTANCES", available_instances);
+ req.setAttribute("SELECTED_INSTANCE", selectedInstance);
+ req.setAttribute("NEW_CONTENT", Boolean.valueOf(newContent));
//
- if (selectedInstance != null)
- {
- writer.print("<div class=\"portlet-font\"
style=\"float:left\">");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet instance:</span>" +
selectedURI + "</div>");
- try
- {
- Portlet portlet = selectedInstance.getPortlet();
- if (portlet != null)
- {
- MetaInfo metaInfo = portlet.getInfo().getMeta();
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet name:</span>" +
metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() +
"</div>");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet description:</span>" +
metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() +
"</div>");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet title:</span>" +
metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() + "</div>");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet keywords:</span>" +
metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() + "</div>");
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
+ PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/WEB-INF/jsp/content/portlet_editor.jsp");
+ dispatcher.include(req, resp);
//
writer.close();
Added: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
(rev 0)
+++
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp 2007-06-20
22:59:02 UTC (rev 7491)
@@ -0,0 +1,81 @@
+<%@ page import="java.util.Collection" %>
+<%@ page import="org.jboss.portal.core.model.instance.Instance" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="javax.portlet.PortletURL" %>
+<%@ page import="org.jboss.portal.common.util.IteratorStatus" %>
+<%@ page import="org.jboss.portal.portlet.Portlet" %>
+<%@ page import="org.jboss.portal.portlet.info.MetaInfo" %>
+<%@ page import="org.jboss.portal.portlet.PortletInvokerException" %>
+<%@ page language="java" %>
+<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet"
%>
+
+<%
+ Collection instances = (Collection)request.getAttribute("INSTANCES");
+ Instance selectedInstance =
(Instance)request.getAttribute("SELECTED_INSTANCE");
+ boolean newContent = Boolean.TRUE == request.getAttribute("NEW_CONTENT");
+%>
+
+<%
+ if (newContent)
+ {
+%>
+ <span class="portlet-font">Portlet instance associated to this
window:</span>
+<%
+ }
+ else
+ {
+%>
+ <span class="portlet-font">Portlet instance associated to this
window:</span>
+<%
+ }
+%>
+
+<div style="height:300px; width:300px; overflow-y: scroll; overflow-x: none;
border: 1px solid #333333;">
+ <table style="width:100%;" cellspacing="0"
cellpadding="0">
+ <%
+ for (IteratorStatus i = new IteratorStatus(instances); i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ String rowClass = instance == selectedInstance ?
"portlet-section-selected" : (i.getIndex() %2 == 0 ?
"portlet-section-body" : "portlet-section-alternate");
+ %>
+ <portlet:actionURL var="url">
+ <portlet:param name="content.action.select"
value="true"/>
+ <portlet:param name="content.uri" value="<%=
instance.getId() %>"/>
+ </portlet:actionURL>
+ <tr class="<%= rowClass %>">
+ <td><a href="<%= url %>"><%= instance.getId()
%></a></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+</div>
+
+<%
+ if (selectedInstance != null)
+ {
+%>
+<div class="portlet-font">
+<div><span class="portlet-form-field-label">Portlet
instance:</span><%= selectedInstance.getId() %></div>
+<%
+ Portlet portlet = null;
+ try
+ {
+ portlet = selectedInstance.getPortlet();
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ if (portlet != null)
+ {
+ MetaInfo metaInfo = portlet.getInfo().getMeta();
+%>
+<div><span class="portlet-form-field-label">Portlet
name:</span><%= metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString()
%></div>
+<div><span class="portlet-form-field-label">Portlet
description:</span><%=
metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() %></div>
+<div><span class="portlet-form-field-label">Portlet
title:</span><%= metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString()
%></div>
+<div><span class="portlet-form-field-label">Portlet
keywords:</span><%= metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString()
%></div>
+<%
+ }
+ }
+%>