Author: julien(a)jboss.com
Date: 2007-02-14 09:30:58 -0500 (Wed, 14 Feb 2007)
New Revision: 6270
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/CharsetPortlet.java
Log:
update charset portlet to test various use case with process action : textarea, text field
and portlet url parameter
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/CharsetPortlet.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/CharsetPortlet.java 2007-02-14
14:15:02 UTC (rev 6269)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/CharsetPortlet.java 2007-02-14
14:30:58 UTC (rev 6270)
@@ -32,6 +32,7 @@
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
import java.io.IOException;
import java.io.PrintWriter;
@@ -131,56 +132,85 @@
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
- //
- 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> Testing range : " +
- "<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>" +
- "<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\">");
+ 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 = EntityTable.FULL.lookup(c);
if (s == null)
{
- writer.print(c);
+ escapedText.append(c);
}
else
{
- writer.print("&" + s + ";");
+ escapedText.append("&").append(s).append(";");
}
}
}
+
+ //
+ 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(
- "</textarea>" +
- "<input type=\"submit\"
value=\"check\"/>" +
- "</form>" +
- "</div>");
+ "<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>");
+
+ //
+ if (same == Boolean.TRUE)
+ {
+ writer.print("<div>Test result: The input matched the expected
result</div>");
+ }
+ else if (same == Boolean.FALSE)
+ {
+ writer.print("<div>Test result: The input did not matched the
expected result</div>");
+ }
+
+ //
writer.close();
}
Show replies by date