Author: julien(a)jboss.com
Date: 2008-06-25 10:09:20 -0400 (Wed, 25 Jun 2008)
New Revision: 11141
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/CharsetPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/EncodingPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PrivateParameterPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PublicParameterPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionCounterPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionPortlet.java
Modified:
modules/portlet/trunk/bridge/pom.xml
modules/portlet/trunk/build/distrib/distrib.xml
modules/portlet/trunk/build/pom.xml
modules/portlet/trunk/controller/pom.xml
modules/portlet/trunk/docs/pom.xml
modules/portlet/trunk/docs/user-guide/pom.xml
modules/portlet/trunk/federation/pom.xml
modules/portlet/trunk/jsr168api/pom.xml
modules/portlet/trunk/management/pom.xml
modules/portlet/trunk/mc/pom.xml
modules/portlet/trunk/pom.xml
modules/portlet/trunk/portal/pom.xml
modules/portlet/trunk/portlet/pom.xml
modules/portlet/trunk/releaseLibs.sh
modules/portlet/trunk/samples/pom.xml
modules/portlet/trunk/test/pom.xml
Log:
update portlet trunk to 2.1.0 snapshot and added a few basic portlet samples migrated from
core samples
Modified: modules/portlet/trunk/bridge/pom.xml
===================================================================
--- modules/portlet/trunk/bridge/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/bridge/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/build/distrib/distrib.xml
===================================================================
--- modules/portlet/trunk/build/distrib/distrib.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/build/distrib/distrib.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -2,9 +2,9 @@
<property name="source.dir" value="../.."/>
<property name="src.docs.dir" value="${source.dir}/docs"/>
- <property name="pc.release.version" value="2.0.0.CR3"/>
- <property name="demo.release.version" value="2.0.0.CR3"/>
- <property name="maven.version" value="2.0.0-SNAPSHOT"/>
+ <property name="pc.release.version" value="2.1.0.CR1"/>
+ <property name="demo.release.version" value="2.1.0.CR1"/>
+ <property name="maven.version" value="2.1.0-SNAPSHOT"/>
<!-- -->
<property name="pc.release.name"
value="jboss-portletcontainer-${pc.release.version}"/>
Modified: modules/portlet/trunk/build/pom.xml
===================================================================
--- modules/portlet/trunk/build/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/build/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JBoss Portal Portlet Module</name>
<description>JBoss Portal Portlet Module</description>
@@ -33,8 +33,8 @@
<version.jboss-logging>2.0.4.GA</version.jboss-logging>
<version.jbossxb>2.0.0.CR8</version.jbossxb>
<version.jboss-remoting>2.2.1.GA</version.jboss-remoting>
-
<version.jboss.portal.common>1.2.0-SNAPSHOT</version.jboss.portal.common>
- <version.jboss.portal.web>1.2.0-SNAPSHOT</version.jboss.portal.web>
+ <version.jboss.portal.common>1.2.0</version.jboss.portal.common>
+ <version.jboss.portal.web>1.2.0</version.jboss.portal.web>
<version.jboss.unit>1.2.0.Beta2</version.jboss.unit>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-logging>1.1.1</version.apache.commons-logging>
Modified: modules/portlet/trunk/controller/pom.xml
===================================================================
--- modules/portlet/trunk/controller/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/controller/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/docs/pom.xml
===================================================================
--- modules/portlet/trunk/docs/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/docs/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<artifactId>docs-aggregator</artifactId>
Modified: modules/portlet/trunk/docs/user-guide/pom.xml
===================================================================
--- modules/portlet/trunk/docs/user-guide/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/docs/user-guide/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -11,7 +11,7 @@
</parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>user-guide-${translation}</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>User_Guide_(${translation})</name>
Modified: modules/portlet/trunk/federation/pom.xml
===================================================================
--- modules/portlet/trunk/federation/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/federation/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/jsr168api/pom.xml
===================================================================
--- modules/portlet/trunk/jsr168api/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/jsr168api/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/management/pom.xml
===================================================================
--- modules/portlet/trunk/management/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/management/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/mc/pom.xml
===================================================================
--- modules/portlet/trunk/mc/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/mc/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/pom.xml
===================================================================
--- modules/portlet/trunk/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -5,7 +5,7 @@
<artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Portlet Module Aggregator</name>
- <version>2.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<
url>http://labs.jboss.com/jbossportal</url>
<dependencies/>
Modified: modules/portlet/trunk/portal/pom.xml
===================================================================
--- modules/portlet/trunk/portal/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/portal/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/portlet/pom.xml
===================================================================
--- modules/portlet/trunk/portlet/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/portlet/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/portlet/trunk/releaseLibs.sh
===================================================================
--- modules/portlet/trunk/releaseLibs.sh 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/releaseLibs.sh 2008-06-25 14:09:20 UTC (rev 11141)
@@ -21,9 +21,9 @@
echo "Releasing to Portal thirdparty"
fi
-cp bridge/target/portlet-bridge-2.0.0-SNAPSHOT.jar $loc/portal-portlet-bridge-lib.jar
-cp controller/target/portlet-controller-2.0.0-SNAPSHOT.jar
$loc/portal-portlet-controller-lib.jar
-cp federation/target/portlet-federation-2.0.0-SNAPSHOT.jar
$loc/portal-portlet-federation-lib.jar
-cp management/target/portlet-management-2.0.0-SNAPSHOT.jar
$loc/portal-portlet-management-lib.jar
-cp portlet/target/portlet-portlet-2.0.0-SNAPSHOT.jar $loc/portal-portlet-lib.jar
-cp samples/target/portlet-samples-2.0.0-SNAPSHOT.jar $loc/portal-portlet-samples-lib.jar
+cp bridge/target/portlet-bridge-2.1.0-SNAPSHOT.jar $loc/portal-portlet-bridge-lib.jar
+cp controller/target/portlet-controller-2.1.0-SNAPSHOT.jar
$loc/portal-portlet-controller-lib.jar
+cp federation/target/portlet-federation-2.1.0-SNAPSHOT.jar
$loc/portal-portlet-federation-lib.jar
+cp management/target/portlet-management-2.1.0-SNAPSHOT.jar
$loc/portal-portlet-management-lib.jar
+cp portlet/target/portlet-portlet-2.1.0-SNAPSHOT.jar $loc/portal-portlet-lib.jar
+cp samples/target/portlet-samples-2.1.0-SNAPSHOT.jar $loc/portal-portlet-samples-lib.jar
Modified: modules/portlet/trunk/samples/pom.xml
===================================================================
--- modules/portlet/trunk/samples/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/samples/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,6 +13,10 @@
<dependencies>
<dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>common-common</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
</dependency>
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/CharsetPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/CharsetPortlet.java
(rev 0)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/CharsetPortlet.java 2008-06-25
14:09:20 UTC (rev 11141)
@@ -0,0 +1,278 @@
+/******************************************************************************
+ * 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.portlet.samples.basic;
+
+import org.jboss.portal.common.text.EntityEncoder;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.ActionResponse;
+import javax.portlet.ActionRequest;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ * This portlet is used to display a form that helps to test the charset handling by the
portal and the client. When a
+ * fault occurs it may be the client fault (for instance the char with unicode value 160
fail the test in firefox but
+ * succeds in IE6).
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CharsetPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ String fromString = req.getParameter("from");
+ String toString = req.getParameter("to");
+ int from;
+ int to;
+ try
+ {
+ from = Integer.parseInt(fromString);
+ to = Integer.parseInt(toString);
+ }
+ catch (NumberFormatException ignore)
+ {
+ from = 65;
+ to = 256;
+ }
+ resp.setRenderParameter("from", "" + from);
+ resp.setRenderParameter("to", "" + to);
+
+ //
+ String text = req.getParameter("text");
+ if (text != null)
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = from; i < to; i++)
+ {
+ char c = (char)i;
+ if (useChar(c))
+ {
+ buffer.append(c);
+ }
+ }
+ String expectedText = buffer.toString();
+ boolean same = expectedText.equals(text);
+ if (!same)
+ {
+ getPortletContext().log("The input does not match the expected
string");
+ getPortletContext().log("Expected string " + expectedText);
+ getPortletContext().log("Received string " + text);
+ }
+ resp.setRenderParameter("same", "" + same);
+ }
+ }
+
+
+ protected void doHelp(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ writer.print("This portlet shows different ways to properly display and submit
unicode text");
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ String sameString = req.getParameter("same");
+ Boolean same = null;
+ if ("true".equalsIgnoreCase(sameString))
+ {
+ same = Boolean.TRUE;
+ }
+ else if ("false".equalsIgnoreCase(sameString))
+ {
+ same = Boolean.FALSE;
+ }
+
+ //
+ String fromString = req.getParameter("from");
+ String toString = req.getParameter("to");
+ int from = 65;
+ int to = 256;
+ try
+ {
+ from = Integer.parseInt(fromString);
+ to = from + 16;
+ to = Integer.parseInt(toString);
+ }
+ catch (NumberFormatException ignore)
+ {
+ //
+ }
+
+ //
+ if (to <= from)
+ {
+ to = from + 16;
+ }
+
+ //
+ StringBuffer escapedText = new StringBuffer();
+ StringBuffer text = new StringBuffer();
+ for (int i = from; i < to; i++)
+ {
+ char c = (char)i;
+ if (useChar(c))
+ {
+ text.append(c);
+ String s = EntityEncoder.FULL.lookup(c);
+ if (s == null)
+ {
+ escapedText.append(c);
+ }
+ else
+ {
+ escapedText.append("&").append(s).append(";");
+ }
+ }
+ }
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ writer.println("<div style=\"border-top:solid 1px\">Testing
range:</div>");
+ writer.print(
+ "<div>" +
+ "<form action=\"" + resp.createActionURL() + "\"
method=\"post\"\">" +
+ "<input type=\"text\" name=\"from\"
value=\"" + from + "\"/>" +
+ "<input type=\"text\" name=\"to\"
value=\"" + to + "\"/>" +
+ "<input type=\"submit\"
value=\"change\"/>" +
+ "</form>" +
+ "</div>");
+
+ //
+ writer.println("<div style=\"border-top:solid 1px\">Test
processAction() with a textarea field:</div>");
+ writer.println(
+ "<div>" +
+ "<form action=\"" + resp.createActionURL() + "\"
accept-charset=\"" + resp.getCharacterEncoding() + "\"
method=\"post\">" +
+ "<input type=\"hidden\" name=\"from\"
value=\"" + from + "\"/>" +
+ "<input type=\"hidden\" name=\"to\"
value=\"" + to + "\"/>" +
+ "<textarea name=\"text\" cols=\"20\"
rows=\"10\" wrap=\"virtual\">" + escapedText +
"</textarea>" +
+ "<input type=\"submit\"
value=\"check\"/>" +
+ "</form>" +
+ "</div>");
+
+ //
+ writer.println("<div style=\"border-top:solid 1px\">Test
processAction() with a text field:</div>");
+ writer.println(
+ "<div>" +
+ "<form action=\"" + resp.createActionURL() + "\"
accept-charset=\"" + resp.getCharacterEncoding() + "\"
method=\"post\">" +
+ "<input type=\"hidden\" name=\"from\"
value=\"" + from + "\"/>" +
+ "<input type=\"hidden\" name=\"to\"
value=\"" + to + "\"/>" +
+ "<input type=\"text\" name=\"text\"
value=\"" + escapedText + "\"/>" +
+ "<input type=\"submit\"
value=\"check\"/>" +
+ "</form>" +
+ "</div>");
+
+ //
+ PortletURL url = resp.createActionURL();
+ url.setParameter("text", text.toString());
+ writer.println("<div style=\"border-top:solid 1px\">Test
processAction() with a portlet parameter:</div>");
+ writer.println(
+ "<div>" +
+ "<form action=\"" + url + "\"
accept-charset=\"" + resp.getCharacterEncoding() + "\"
method=\"post\">" +
+ "<input type=\"hidden\" name=\"from\"
value=\"" + from + "\"/>" +
+ "<input type=\"hidden\" name=\"to\"
value=\"" + to + "\"/>" +
+ "<input type=\"submit\"
value=\"check\"/>" +
+ "</form>" +
+ "</div>");
+
+ //
+ PortletURL url2 = resp.createActionURL();
+ url2.setParameter("text", text.toString());
+ url2.setParameter("from", "" + from);
+ url2.setParameter("to", "" + to);
+ writer.println("<div style=\"border-top:solid 1px\"><a
href=\"" + url2 + "\">Test</a> processAction() with a portlet
parameter:</div>");
+
+ //
+ if (same != null)
+ {
+ writer.print("<div
style=\"color:red;margin-top:2em;margin-bottom:2em\">Test result: ");
+ if (same == Boolean.TRUE)
+ {
+ writer.print("The input matched the expected result");
+ }
+ else if (same == Boolean.FALSE)
+ {
+ writer.print("The input did not matched the expected result");
+ }
+ writer.print("</div>");
+ }
+
+ //
+ writer.close();
+ }
+
+ public static boolean useChar(char c)
+ {
+ switch (Character.getType(c))
+ {
+ case Character.LOWERCASE_LETTER: // Ll
+ case Character.UPPERCASE_LETTER: // Lu
+ case Character.TITLECASE_LETTER: // Lt
+ case Character.MODIFIER_LETTER: // Lm
+ case Character.OTHER_LETTER: // Lo
+ case Character.NON_SPACING_MARK: // Mn
+ case Character.ENCLOSING_MARK: // Me
+ case Character.COMBINING_SPACING_MARK: // Mc
+ case Character.DECIMAL_DIGIT_NUMBER: // Nd
+ case Character.LETTER_NUMBER: // Nl
+ case Character.OTHER_NUMBER: // No
+ case Character.SPACE_SEPARATOR: // Zs
+ case Character.LINE_SEPARATOR: // Zl
+ case Character.PARAGRAPH_SEPARATOR: // Zp
+ case Character.DASH_PUNCTUATION: // Pd
+ case Character.START_PUNCTUATION: // Ps
+ case Character.END_PUNCTUATION: // Pe
+ case Character.CONNECTOR_PUNCTUATION: // Pc
+ case Character.OTHER_PUNCTUATION: // Po
+ case Character.INITIAL_QUOTE_PUNCTUATION: // Pi
+ case Character.FINAL_QUOTE_PUNCTUATION: // Pf
+ case Character.MATH_SYMBOL: // Sm
+ case Character.CURRENCY_SYMBOL: // Sc
+ case Character.MODIFIER_SYMBOL: // Sk
+ case Character.OTHER_SYMBOL: // So
+ return true;
+ default:
+ case Character.UNASSIGNED: // Cn
+ case Character.CONTROL: // Cc
+ case Character.FORMAT: // Cf
+ case Character.PRIVATE_USE: // Co
+ case Character.SURROGATE: // Cs
+ return false;
+ }
+ }
+
+}
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/EncodingPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/EncodingPortlet.java
(rev 0)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/EncodingPortlet.java 2008-06-25
14:09:20 UTC (rev 11141)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * 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.portlet.samples.basic;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EncodingPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ resp.setRenderParameter("text", req.getParameter("text"));
+ req.getPortletSession().setAttribute("text",
req.getParameter("text"));
+
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ String param = req.getParameter("text");
+ String attr = (String)req.getPortletSession().getAttribute("text");
+
+ //
+ writer.print(
+ "<div> Text to pass : " +
+ "<form action=\"" + resp.createRenderURL() + "\"
method=\"post\"\">" +
+ "<input type=\"text\" name=\"text\"
value=\"\"/>" +
+ "<input type=\"submit\" value=\"Submit to render
phase\"/>" +
+ "</form>" +
+ "<form action=\"" + resp.createActionURL() + "\"
method=\"post\"\">" +
+ "<input type=\"text\" name=\"text\"
value=\"\"/>" +
+ "<input type=\"submit\" value=\"Submit to action
phase\"/>" +
+ "</form>" +
+ "</div>");
+
+ //
+ writer.println(
+ "<div>" + "Text retrieved from request parameter: " +
+ "</div>" +
+ "<div>" +
+ "<textarea name=\"text\" cols=\"20\"
rows=\"4\" wrap=\"virtual\">");
+
+ if (param != null)
+ {
+ writer.println(param);
+ }
+
+ writer.println(
+ "</textarea>" +
+ "</div>");
+
+ writer.println(
+ "<div>" + "Text retrieved from portlet session (value set
during Action Phase): " +
+ "</div>" +
+ "<div>" +
+ "<textarea name=\"text\" cols=\"20\"
rows=\"4\" wrap=\"virtual\">");
+
+ if (attr != null)
+ {
+ writer.println(attr);
+ }
+
+ writer.println(
+ "</textarea>" +
+ "</div>");
+
+ //
+ writer.close();
+ }
+}
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PrivateParameterPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PrivateParameterPortlet.java
(rev 0)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PrivateParameterPortlet.java 2008-06-25
14:09:20 UTC (rev 11141)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * 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.portlet.samples.basic;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionResponse;
+import javax.portlet.ActionRequest;
+import java.util.Enumeration;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PrivateParameterPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, IOException
+ {
+ for (Enumeration e = req.getParameterNames(); e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ String value = req.getParameter(name);
+ if (!"name".equals(name) && !"value".equals(name))
+ {
+ resp.setRenderParameter(name, value);
+ }
+ }
+ String name = req.getParameter("name");
+ String value = req.getParameter("value");
+ if (name != null && value != null)
+ {
+ resp.setRenderParameter(name, value);
+ }
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
+ {
+ String color = req.getParameter("color");
+ if (color == null)
+ {
+ color = "white";
+ }
+
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ PortletURL renderURL = resp.createRenderURL();
+
+ //
+ renderURL.setParameter("color", "blue");
+ String blueURL = renderURL.toString();
+
+ //
+ renderURL.setParameter("color", "red");
+ String redURL = renderURL.toString();
+
+ //
+ renderURL.setParameter("color", "white");
+ String whiteURL = renderURL.toString();
+
+ //
+ writer.print("<a href=\"" + blueURL +
"\">blue</a> -");
+ writer.print("<a href=\"" + redURL +
"\">red</a> -");
+ writer.print("<a href=\"" + whiteURL +
"\">white</a><br/>");
+
+ //
+ writer.print("Parameters :<br/>");
+ writer.print("<table bgcolor=\"" + color +
"\">");
+
writer.print("<tr><td>Name</td><td>value</td></tr>");
+ for (Enumeration e = req.getParameterNames(); e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ String value = req.getParameter(name);
+ writer.print("<tr><td>" + name +
"</td><td>" + value + "</td></tr>");
+ }
+ writer.print("</table>");
+
+ //
+ PortletURL actionURL = resp.createActionURL();
+ writer.print("<form action=\"" + actionURL.toString() +
"\" method=\"post\">");
+ writer.print("<input type=\"text\"
name=\"name\"/>");
+ writer.print("<input type=\"text\"
name=\"value\"/>");
+ writer.print("<input type=\"submit\"
value=\"add\"/>");
+ writer.print("</form>");
+
+ //
+ writer.print("<a href=\"" + req.getContextPath() +
"/test.txt\">test</a>");
+
+ //
+ writer.close();
+ }
+}
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PublicParameterPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PublicParameterPortlet.java
(rev 0)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/PublicParameterPortlet.java 2008-06-25
14:09:20 UTC (rev 11141)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * 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.portlet.samples.basic;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletException;
+import javax.portlet.ProcessAction;
+import javax.portlet.RenderRequest;
+import java.util.Enumeration;
+import java.util.Map;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PublicParameterPortlet extends GenericPortlet
+{
+
+ @ProcessAction(name="update")
+ public void update(ActionRequest req, ActionResponse resp) throws PortletException,
IOException
+ {
+ Map<String, String[]> publicParameters = req.getPublicParameterMap();
+
+ //
+ for (Map.Entry<String, String[]> actionParameter :
req.getPrivateParameterMap().entrySet())
+ {
+ String parameterName = actionParameter.getKey();
+ String parameterValue = actionParameter.getValue()[0];
+ String[] publicValues = publicParameters.get(parameterName);
+
+ //
+ if (parameterValue.length() > 0)
+ {
+ if (publicValues == null || !publicValues[0].equals(parameterValue))
+ {
+ resp.setRenderParameter(parameterName, parameterValue);
+ }
+ }
+ else if (publicValues != null)
+ {
+ resp.removePublicRenderParameter(parameterName);
+ }
+ }
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
+ {
+ PortletURL actionURL = resp.createActionURL();
+ actionURL.setParameter(ActionRequest.ACTION_NAME, "update");
+
+ //
+ 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
+ "\"/>");
+
+ //
+ PortletURL renderURL = resp.createRenderURL();
+ renderURL.removePublicRenderParameter(parameterName);
+ writer.println("<a href=\"" + renderURL +
"\">Remove</>");
+ }
+ else
+ {
+ writer.print("<input type=\"text\" name=\"" +
parameterName + "\" width=\"36\" value=\"\"/>");
+ }
+ writer.println();
+
+ writer.println("</td>");
+
+ }
+
+ writer.println("<input type=\"submit\"
value=\"Update\"/>");
+
+ writer.print("</table></form>");
+
+ //
+ writer.close();
+ }
+}
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionCounterPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionCounterPortlet.java
(rev 0)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionCounterPortlet.java 2008-06-25
14:09:20 UTC (rev 11141)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.portlet.samples.basic;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.ActionResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SessionCounterPortlet extends GenericPortlet
+{
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, IOException
+ {
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ PortletSession session = req.getPortletSession();
+ int count = 0;
+ if (session.getAttribute("count") != null)
+ {
+ count = (Integer)session.getAttribute("count") + 1;
+ }
+ session.setAttribute("count", count);
+ writer.write("<p>");
+ writer.write("<div class=\"portlet-section-header\">Render
call count</div>");
+ writer.write("<div class=\"portlet-section-body\">");
+ writer.write("<div>" + count + "</div>");
+ writer.write("</div>");
+ writer.write("</p>");
+
+ writer.write("<div class=\"portlet-section-header\">Render
call count</div>");
+ writer.write("<div><a href=\"" + resp.createActionURL() +
"\">action</a></div");
+ writer.write("<div><a href=\"" + resp.createRenderURL() +
"\">render</a></div");
+
+ //
+ writer.close();
+ }
+}
Added:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionPortlet.java
(rev 0)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/SessionPortlet.java 2008-06-25
14:09:20 UTC (rev 11141)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * 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.portlet.samples.basic;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletSession;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.RenderRequest;
+import java.io.PrintWriter;
+import java.io.IOException;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SessionPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, IOException
+ {
+ String name = req.getParameter("name");
+ String value = req.getParameter("value");
+ boolean portletScope = req.getParameter("portlet") != null;
+ if (name != null && value != null)
+ {
+ req.getPortletSession().setAttribute(name, value, portletScope ?
PortletSession.PORTLET_SCOPE : PortletSession.APPLICATION_SCOPE);
+ }
+ if (req.getParameter("invalidate") != null)
+ {
+ req.getPortletSession().invalidate();
+ }
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
+ {
+ PortletSession session = req.getPortletSession(false);
+ PortletURL purl = resp.createActionURL();
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ if (session == null)
+ {
+ writer.println("No session");
+ }
+ else
+ {
+ writer.println("Session id = " + session.getId());
+ writer.println("<br/>");
+
+ //
+ print(session, PortletSession.PORTLET_SCOPE, writer);
+ writer.println("<br/>");
+
+ //
+ print(session, PortletSession.APPLICATION_SCOPE, writer);
+ writer.println("<br/>");
+
+ }
+
+ //
+ writer.println("<form action=\"" + purl.toString() +
"\" method=\"post\">");
+ writer.println("<input type=\"text\"
name=\"name\"/>");
+ writer.println("<input type=\"text\"
name=\"value\"/>");
+ writer.println("<input type=\"submit\" name=\"portlet\"
value=\"Add to portlet scope\"/>");
+ writer.println("<input type=\"submit\"
name=\"application\" value=\"Add to application scope\"/>");
+ writer.println("</form><br/>");
+
+ //
+ purl.setParameter("invalidate", "true");
+ writer.println("<a href=\"" + purl.toString() +
"\">invalidate</a><br/>");
+ }
+
+ private void print(PortletSession session, int scope, PrintWriter writer)
+ {
+ String scopeName = PortletSession.PORTLET_SCOPE == scope ? "portlet" :
"application";
+ writer.println("<p style='border-bottom: 2px dashed
#999;'>Session attributes for " + scopeName + " scope:</p>");
+ Enumeration e = session.getAttributeNames(scope);
+ if (e.hasMoreElements())
+ {
+ writer.println("<table style='border: 1px solid
#333;'>");
+ writer.println("<tr
class='portlet-table-header'><th>name</th><th>value</th>");
+ for (; e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ Object value = session.getAttribute(name, scope);
+ writer.println("<tr><td>" + name +
"</td><td>" + value + "</td>");
+ }
+ writer.println("</table>");
+ }
+ else
+ {
+ writer.println("<p>No attributes in " + scopeName + "
scope!</p>");
+ }
+ }
+}
Modified: modules/portlet/trunk/test/pom.xml
===================================================================
--- modules/portlet/trunk/test/pom.xml 2008-06-25 13:25:00 UTC (rev 11140)
+++ modules/portlet/trunk/test/pom.xml 2008-06-25 14:09:20 UTC (rev 11141)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>module-parent</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>