Author: julien(a)jboss.com
Date: 2007-03-20 09:18:41 -0400 (Tue, 20 Mar 2007)
New Revision: 6774
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/ExceptionPortlet.java
Log:
slight improvements in ExceptionPortlet
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/ExceptionPortlet.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/ExceptionPortlet.java 2007-03-20
13:02:58 UTC (rev 6773)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/ExceptionPortlet.java 2007-03-20
13:18:41 UTC (rev 6774)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.portlet.test;
-import org.jboss.portlet.JBossPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-
import javax.portlet.PortletException;
import javax.portlet.PortletSecurityException;
import javax.portlet.PortletURL;
+import javax.portlet.GenericPortlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
import java.io.IOException;
import java.io.PrintWriter;
@@ -36,30 +38,17 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5448 $
*/
-public class ExceptionPortlet extends JBossPortlet
+public class ExceptionPortlet extends GenericPortlet
{
- protected void doView(JBossRenderRequest req, JBossRenderResponse resp) throws
PortletException, PortletSecurityException, IOException
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
{
- String op = req.getParameter("op");
+ throwException(req);
+ }
- // Throw any required exception
- if ("portletexception".equals(op))
- {
- throw new PortletException();
- }
- if ("portletsecurityexception".equals(op))
- {
- throw new PortletSecurityException("");
- }
- if ("ioexception".equals(op))
- {
- throw new IOException();
- }
- if ("runtimeexception".equals(op))
- {
- throw new RuntimeException();
- }
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ throwException(req);
//
resp.setContentType("text/html");
@@ -79,6 +68,8 @@
writer.write("<div><a href=\"" + renderURL +
"\">render IOException</a></div>");
renderURL.setParameter("op", "runtimeexception");
writer.write("<div><a href=\"" + renderURL +
"\">render RuntimeException</a></div>");
+ actionURL.setParameter("op", "error");
+ writer.write("<div><a href=\"" + renderURL +
"\">render Error</a></div>");
actionURL.setParameter("op", "portletexception");
writer.write("<div><a href=\"" + actionURL +
"\">action PortletException</a></div>");
actionURL.setParameter("op", "portletsecurityexception");
@@ -87,7 +78,36 @@
writer.write("<div><a href=\"" + actionURL +
"\">action IOException</a></div>");
actionURL.setParameter("op", "runtimeexception");
writer.write("<div><a href=\"" + actionURL +
"\">action RuntimeException</a></div>");
+ actionURL.setParameter("op", "error");
+ writer.write("<div><a href=\"" + actionURL +
"\">action Error</a></div>");
writer.write("</div>");
writer.write("</p>");
}
+
+ private void throwException(PortletRequest req) throws PortletException, IOException
+ {
+ String op = req.getParameter("op");
+
+ // Throw any required exception
+ if ("portletexception".equals(op))
+ {
+ throw new PortletException();
+ }
+ if ("portletsecurityexception".equals(op))
+ {
+ throw new PortletSecurityException("");
+ }
+ if ("ioexception".equals(op))
+ {
+ throw new IOException();
+ }
+ if ("runtimeexception".equals(op))
+ {
+ throw new RuntimeException();
+ }
+ if ("error".equals(op))
+ {
+ throw new Error();
+ }
+ }
}
Show replies by date