Author: thomas.heute(a)jboss.com
Date: 2008-06-27 09:06:21 -0400 (Fri, 27 Jun 2008)
New Revision: 11169
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/FSContentDrivenPortlet.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/portlet.xml
Log:
Imrpove content selectors
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2008-06-27
12:08:04 UTC (rev 11168)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2008-06-27
13:06:21 UTC (rev 11169)
@@ -104,8 +104,13 @@
protected void getContent(RenderRequest req, RenderResponse resp, boolean newContent)
throws PortletException, PortletSecurityException, IOException
{
- String selectedURI = req.getParameter(CONTENT_URI);
-
+ String selectedURI = req.getParameter("current_uri");
+ if (selectedURI == null)
+ {
+ // Get the uri value optionally provided by the portal
+ selectedURI = req.getParameter("uri");
+ }
+
//
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/portlet.xml 2008-06-27
12:08:04 UTC (rev 11168)
+++
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/portlet.xml 2008-06-27
13:06:21 UTC (rev 11169)
@@ -43,6 +43,7 @@
<keywords>management,admin</keywords>
</portlet-info>
<supported-publishing-event
xmlns:x="urn:jboss:portal:content">x:select</supported-publishing-event>
+
<supported-public-render-parameter>uri</supported-public-render-parameter>
</portlet>
<user-attribute>
<name>user.name.nickName</name>
@@ -57,9 +58,14 @@
<name>user.name.family</name>
</user-attribute>
- <event-definition>
- <qname xmlns:x="urn:jboss:portal:content">x:select</qname>
- <value-type>java.lang.String</value-type>
- </event-definition>
+ <event-definition>
+ <qname xmlns:x="urn:jboss:portal:content">x:select</qname>
+ <value-type>java.lang.String</value-type>
+ </event-definition>
+ <public-render-parameter>
+ <identifier>uri</identifier>
+ <qname xmlns:c="urn:jboss:portal:content">c:uri</qname>
+ </public-render-parameter>
+
</portlet-app>
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2008-06-27
12:08:04 UTC (rev 11168)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2008-06-27
13:06:21 UTC (rev 11169)
@@ -61,7 +61,6 @@
import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.faces.component.portlet.PortletActionEvent;
import org.jboss.portal.faces.component.portlet.PortletEventEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.portlet.Portlet;
@@ -82,9 +81,6 @@
/** The serialVersionUID */
private static final long serialVersionUID = -8923517554726982622L;
- /** . */
- private static final String CONTENT_URI = "content.uri";
-
private static final QName CONTENT_SELECT = new
QName("urn:jboss:portal:content", "select");
// Configuration
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2008-06-27
12:08:04 UTC (rev 11168)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2008-06-27
13:06:21 UTC (rev 11169)
@@ -35,7 +35,6 @@
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.faces.component.portlet.PortletActionEvent;
import org.jboss.portal.faces.component.portlet.PortletEventEvent;
import org.jboss.portal.faces.component.portlet.PortletRenderEvent;
import org.jboss.portal.faces.el.PropertyValue;
@@ -71,18 +70,6 @@
public class PageManagerBean
{
- /** . */
- private static final String CONTENT_ACTION_SELECT =
"content.action.select";
-
- /** . */
- private static final String CONTENT_URI = "content.uri";
-
- /** . */
- private static final String CONTENT_PARAM_PREFIX = "content.param.";
-
- /** . */
- private static final int CONTENT_PARAM_PREFIX_LENGTH = CONTENT_PARAM_PREFIX.length();
-
private static final QName CONTENT_SELECT = new
QName("urn:jboss:portal:content", "select");
/** . */
@@ -103,7 +90,7 @@
this.layoutService = layoutService;
this.portletInvoker = portletInvoker;
this.selectedContentType = ContentType.PORTLET;
- this.selectedRenderParameters = new HashMap();
+ this.selectedRenderParameters = new HashMap<String, String>();
}
/** . */
@@ -431,50 +418,6 @@
}
}
}
- /*
- else if (event instanceof PortletActionEvent)
- {
- PortletActionEvent actionEvent = (PortletActionEvent)event;
- Map actionParams = actionEvent.getParameterMap();
-*/
- /*
- // Keep window name and region defined
- String[] windowNames = ((String[])actionParams.get("windowName"));
- if (windowNames != null && windowNames.length > 0)
- {
- setWindowName(windowNames[0]);
- }
- */
- /*
- //
- if (actionParams.get(CONTENT_ACTION_SELECT) != null)
- {
- String[] uris = (String[])actionParams.get(CONTENT_URI);
- if (uris != null && uris.length > 0)
- {
- String uri = uris[0];
-
- //
- Map parameters = new HashMap();
- for (Iterator i = actionParams.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = (String)entry.getKey();
- if (name.startsWith(CONTENT_PARAM_PREFIX))
- {
- String paramName = name.substring(CONTENT_PARAM_PREFIX_LENGTH);
- String paramValue = ((String[])entry.getValue())[0];
- parameters.put(paramName, paramValue);
- }
- }
-
- //
- this.selectedContentURI = uri;
- this.selectedContentParameters = parameters;
- }
- }
- */
-// }
}
/** Return the <Region>List on the selected object which must be a page. */
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2008-06-27
12:08:04 UTC (rev 11168)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2008-06-27
13:06:21 UTC (rev 11169)
@@ -111,6 +111,12 @@
String sPath = req.getParameter("path");
String contentUri = req.getParameter("content.uri");
+ if (contentUri == null)
+ {
+ // Get the uri value optionally provided by the portal
+ contentUri = req.getParameter("uri");
+ }
+
if (sPath == null)
{
sPath = "/";
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/FSContentDrivenPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/FSContentDrivenPortlet.java 2008-06-27
12:08:04 UTC (rev 11168)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/FSContentDrivenPortlet.java 2008-06-27
13:06:21 UTC (rev 11169)
@@ -50,6 +50,7 @@
* <p>Content URI is defined as the canonical path of the file relative to the war
file context root.</p>
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision: 1.1 $
*/
public class FSContentDrivenPortlet extends GenericPortlet
@@ -58,6 +59,7 @@
/** The edit_content mode. */
public static final PortletMode EDIT_CONTENT_MODE = new
PortletMode("edit_content");
+ /** The QName of the event for the portal */
private static final QName CONTENT_SELECT = new
QName("urn:jboss:portal:content", "select");
@@ -77,15 +79,20 @@
/** Implements the edit content functionnality. */
protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
-
- // Get the uri value optionally provided by the portal
- String uri = req.getParameter("content.uri");
+ String uri = req.getParameter("current_uri");
+ if (uri == null)
+ {
+ // Get the uri value optionally provided by the portal
+ uri = req.getParameter("uri");
+ }
// Get the working directory directory
- File workingDir;
+ File workingDir = null;
+ String currentFileName = null;
if (uri != null)
{
workingDir = getFile(uri).getParentFile();
+ currentFileName = getFile(uri).getName();
}
else
{
@@ -132,14 +139,20 @@
writer.print("Files:<br/>");
writer.print("<ul>");
PortletURL selectFileURL = resp.createActionURL();
- selectFileURL.setParameter("content.action.select", "select");
for (int i = 0; i < children.length; i++)
{
File child = children[i];
if (child.isFile())
{
- selectFileURL.setParameter("content.uri", getContentURI(child));
- writer.print("<li><a href=\"" + selectFileURL +
"\">" + child.getName() + "</a></li>");
+ selectFileURL.setParameter("current_uri", getContentURI(child));
+ if (child.getName().equals(currentFileName))
+ {
+ writer.print("<li><b>" + child.getName() +
"</b></li>");
+ }
+ else
+ {
+ writer.print("<li><a href=\"" + selectFileURL +
"\">" + child.getName() + "</a></li>");
+ }
}
}
writer.print("</ul><br/>");
@@ -198,12 +211,14 @@
{
if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
{
- String contentURI = req.getParameter("content.uri");
+ String contentURI = req.getParameter("current_uri");
// We just propagate the content URI as a render parameter for the doEditContent
method
if (contentURI != null)
{
- resp.setRenderParameter("content.uri", contentURI);
+ resp.setRenderParameter("current_uri", contentURI);
+
+ // Tell the portal which URI has been selected by the user
resp.setEvent(CONTENT_SELECT, contentURI);
}
}