Author: julien(a)jboss.com
Date: 2008-07-23 09:52:37 -0400 (Wed, 23 Jul 2008)
New Revision: 11558
Added:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PageParameterPortlet.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/default-object.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet-instances.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet.xml
Log:
added page parameter portlet to update page nav state dirctly using the PortalNode api
Added:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PageParameterPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PageParameterPortlet.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PageParameterPortlet.java 2008-07-23
13:52:37 UTC (rev 11558)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.samples.basic;
+
+import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.node.PortalNodeURL;
+import org.jboss.portlet.JBossRenderRequest;
+import org.jboss.portlet.JBossPortlet;
+import org.jboss.portlet.JBossRenderResponse;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageParameterPortlet extends JBossPortlet
+{
+
+ protected void processAction(JBossActionRequest req, JBossActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ String name = req.getParameter("name");
+ String value = req.getParameter("value");
+
+ //
+ PortalNode page = req.getPortalNode().getParent();
+ PortalNodeURL url = resp.createRenderURL(page);
+ url.setParameter(name, value);
+
+ //
+ resp.sendRedirect(url.toString());
+ }
+
+ protected void doView(JBossRenderRequest req, JBossRenderResponse resp) throws
PortletException, IOException
+ {
+
+ //
+ PrintWriter writer = resp.getWriter();
+
+ //
+ for (Enumeration<String> e =
getPortletConfig().getPublicRenderParameterNames();e.hasMoreElements();)
+ {
+ String parameterName = e.nextElement();
+
+ //
+ writer.println("<li>" + parameterName +
"</li>");
+ }
+
+ //
+ writer.println("<form action=\"" + resp.createActionURL() +
"\" method=\"POST\"><table>");
+ writer.println("<tr><td>Page parameter
name:</td><td><input type=\"text\" name=\"name\"
width=\"36\" value=\"\"/></td></tr>");
+ writer.println("<tr><td>Page parameter
value:</td><td><input type=\"text\" name=\"value\"
width=\"36\" value=\"\"/></td></tr>");
+ writer.println("<tr><td colspan=\"2\"><input
type=\"submit\" value=\"Update\"/></td></tr>");
+ writer.println("</table></form>");
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java 2008-07-23
13:47:24 UTC (rev 11557)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java 2008-07-23
13:52:37 UTC (rev 11558)
@@ -78,19 +78,18 @@
//
PrintWriter writer = resp.getWriter();
+
+ //
writer.print("<form action=\"" + actionURL + "\"
method=\"POST\"><table>");
//
for (Enumeration<String> e =
getPortletConfig().getPublicRenderParameterNames();e.hasMoreElements();)
{
String parameterName = e.nextElement();
-
- //
String parameterValue = req.getParameter(parameterName);
//
writer.print("<tr><td>" + parameterName +
"</td><td>");
-
if (parameterValue != null)
{
writer.print("<input type=\"text\" name=\"" +
parameterName + "\" width=\"36\" value=\"" + parameterValue
+ "\"/>");
@@ -105,13 +104,12 @@
writer.print("<input type=\"text\" name=\"" +
parameterName + "\" width=\"36\" value=\"\"/>");
}
writer.println();
-
- writer.println("</td>");
-
+ writer.println("</td></tr>");
}
- writer.println("<input type=\"submit\"
value=\"Update\"/>");
+ //
+ writer.println("<tr><td colspan=\"2\"><input
type=\"submit\" value=\"Update\"/></td></tr>");
writer.print("</table></form>");
//
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/default-object.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/default-object.xml 2008-07-23
13:47:24 UTC (rev 11557)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/default-object.xml 2008-07-23
13:52:37 UTC (rev 11558)
@@ -315,6 +315,12 @@
<region>center</region>
<height>1</height>
</window>
+ <window>
+ <window-name>PageParameterPortletWindow</window-name>
+ <instance-ref>PageParameterPortletInstance</instance-ref>
+ <region>center</region>
+ <height>2</height>
+ </window>
<coordination>
<parameter-strategy>EXPLICIT</parameter-strategy>
@@ -395,6 +401,12 @@
<region>center</region>
<height>1</height>
</window>
+ <window>
+ <window-name>PageParameterPortletWindow</window-name>
+ <instance-ref>PageParameterPortletInstance</instance-ref>
+ <region>center</region>
+ <height>2</height>
+ </window>
<coordination>
<parameter-strategy>EXPLICIT</parameter-strategy>
@@ -525,6 +537,12 @@
<region>center</region>
<height>1</height>
</window>
+ <window>
+ <window-name>PageParameterPortletWindow</window-name>
+ <instance-ref>PageParameterPortletInstance</instance-ref>
+ <region>center</region>
+ <height>2</height>
+ </window>
<coordination>
<parameter-strategy>IMPLICIT</parameter-strategy>
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet-instances.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet-instances.xml 2008-07-23
13:47:24 UTC (rev 11557)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet-instances.xml 2008-07-23
13:52:37 UTC (rev 11558)
@@ -53,4 +53,10 @@
<portlet-ref>CoordinationShoppingCart</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>PageParameterPortletInstance</instance-id>
+ <portlet-ref>PageParameterPortlet</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet.xml 2008-07-23
13:47:24 UTC (rev 11557)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-coordination-samples-war/WEB-INF/portlet.xml 2008-07-23
13:52:37 UTC (rev 11558)
@@ -98,6 +98,33 @@
</supported-processing-event>
</portlet>
+ <portlet>
+ <description>Page Parameter Portlet</description>
+ <portlet-name>PageParameterPortlet</portlet-name>
+ <display-name>Page Parameter Portlet</display-name>
+
<portlet-class>org.jboss.portal.core.samples.basic.PageParameterPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Page Parameter Portlet</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ </portlet>
+
+ <filter>
+ <filter-name>JBoss Portlet Filter</filter-name>
+
<filter-class>org.jboss.portlet.filter.JBossPortletFilter</filter-class>
+ <lifecycle>ACTION_PHASE</lifecycle>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>JBoss Portlet Filter</filter-name>
+ <portlet-name>PageParameterPortlet</portlet-name>
+ </filter-mapping>
+
<event-definition>
<qname
xmlns:jbp="urn:jboss:portal:samples:event">jbp:CartEvent</qname>
<value-type>org.jboss.portal.portlet.samples.shoppingcart.CartEvent</value-type>