Author: thomas.heute(a)jboss.com
Date: 2008-07-09 09:23:00 -0400 (Wed, 09 Jul 2008)
New Revision: 11366
Added:
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/JSPHelloUserPortlet.java
examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/default-object.xml
examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet-instances.xml
examples/trunk/JSPHelloUser/src/main/webapp/jsp/
examples/trunk/JSPHelloUser/src/main/webapp/jsp/edit.jsp
examples/trunk/JSPHelloUser/src/main/webapp/jsp/hello.jsp
examples/trunk/JSPHelloUser/src/main/webapp/jsp/help.jsp
examples/trunk/JSPHelloUser/src/main/webapp/jsp/welcome.jsp
Removed:
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/SimplestHelloWorldPortlet.java
Modified:
examples/trunk/JSPHelloUser/pom.xml
examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet.xml
Log:
JSP Hello User example
Modified: examples/trunk/JSPHelloUser/pom.xml
===================================================================
--- examples/trunk/JSPHelloUser/pom.xml 2008-07-09 13:12:32 UTC (rev 11365)
+++ examples/trunk/JSPHelloUser/pom.xml 2008-07-09 13:23:00 UTC (rev 11366)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.portal.example</groupId>
- <artifactId>HelloWorld</artifactId>
+ <artifactId>JSPHelloUser</artifactId>
<packaging>war</packaging>
<name />
<version>0.0.1</version>
Copied:
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/JSPHelloUserPortlet.java
(from rev 11363,
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/SimplestHelloWorldPortlet.java)
===================================================================
---
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/JSPHelloUserPortlet.java
(rev 0)
+++
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/JSPHelloUserPortlet.java 2008-07-09
13:23:00 UTC (rev 11366)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * 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;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.UnavailableException;
+
+public class JSPHelloUserPortlet extends GenericPortlet
+{
+
+ public void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
+ {
+ String sYourName = (String) request.getParameter("yourname");
+ if (sYourName != null)
+ {
+ request.setAttribute("yourname", sYourName);
+ PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher("/jsp/hello.jsp");
+ prd.include(request, response);
+ }
+ else
+ {
+ PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher("/jsp/welcome.jsp");
+ prd.include(request, response);
+ }
+ }
+
+ public void processAction(ActionRequest aRequest, ActionResponse aResponse) throws
PortletException, IOException,
+ UnavailableException
+ {
+ String sYourname = (String) aRequest.getParameter("yourname");
+ aResponse.setRenderParameter("yourname", sYourname);
+ }
+
+ protected void doHelp(RenderRequest rRequest, RenderResponse rResponse) throws
PortletException, IOException,
+ UnavailableException
+ {
+ rResponse.setContentType("text/html");
+ PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher("/jsp/help.jsp");
+ prd.include(rRequest, rResponse);
+ }
+
+ protected void doEdit(RenderRequest rRequest, RenderResponse rResponse) throws
PortletException, IOException,
+ UnavailableException
+ {
+ rResponse.setContentType("text/html");
+ PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher("/jsp/edit.jsp");
+ prd.include(rRequest, rResponse);
+ }
+
+}
Deleted:
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/SimplestHelloWorldPortlet.java
===================================================================
---
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/SimplestHelloWorldPortlet.java 2008-07-09
13:12:32 UTC (rev 11365)
+++
examples/trunk/JSPHelloUser/src/main/java/org/jboss/portal/portlet/samples/SimplestHelloWorldPortlet.java 2008-07-09
13:23:00 UTC (rev 11366)
@@ -1,53 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.portlet.GenericPortlet;
-import javax.portlet.PortletException;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class SimplestHelloWorldPortlet extends GenericPortlet
-{
- public void doView(RenderRequest request, RenderResponse response) throws
PortletException
- {
- try
- {
- PrintWriter writer = response.getWriter();
- writer.write("Hello World !");
- writer.close();
- }
- catch (IOException e)
- {
- throw new PortletException(e);
- }
- }
-}
-
Added: examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/default-object.xml
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/default-object.xml
(rev 0)
+++ examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/default-object.xml 2008-07-09
13:23:00 UTC (rev 11366)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE deployments PUBLIC
+ "-//JBoss Portal//DTD Portal Object 2.6//EN"
+ "http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
+<deployments>
+ <deployment>
+ <parent-ref>default</parent-ref>
+ <if-exists>overwrite</if-exists>
+ <page>
+ <page-name>JSPHelloUser</page-name>
+ <window>
+ <window-name>JSPHelloUserWindow</window-name>
+ <instance-ref>JSPHelloUserInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ </deployment>
+</deployments>
\ No newline at end of file
Property changes on:
examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/default-object.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet-instances.xml
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet-instances.xml
(rev 0)
+++ examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet-instances.xml 2008-07-09
13:23:00 UTC (rev 11366)
@@ -0,0 +1,34 @@
+<?xml version="1.0" standalone="yes"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<!DOCTYPE deployments PUBLIC
+ "-//JBoss Portal//DTD Portlet Instances 2.6//EN"
+ "http://www.jboss.org/portlet/dtd/portlet-instances_2_6.dtd">
+<deployments>
+ <deployment>
+ <instance>
+ <instance-id>JSPHelloUserInstance</instance-id>
+ <portlet-ref>JSPHelloUserPortlet</portlet-ref>
+ </instance>
+ </deployment>
+</deployments>
\ No newline at end of file
Property changes on:
examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet-instances.xml
___________________________________________________________________
Name: svn:executable
+ *
Modified: examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet.xml 2008-07-09 13:12:32
UTC (rev 11365)
+++ examples/trunk/JSPHelloUser/src/main/webapp/WEB-INF/portlet.xml 2008-07-09 13:23:00
UTC (rev 11366)
@@ -5,15 +5,18 @@
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">
<portlet>
- <portlet-name>HelloWorldPortlet</portlet-name>
+ <portlet-name>JSPHelloUserPortlet</portlet-name>
<portlet-class>
- org.jboss.portal.portlet.samples.SimplestHelloWorldPortlet
+ org.jboss.portal.portlet.samples.JSPHelloUserPortlet
</portlet-class>
<supports>
<mime-type>text/html</mime-type>
+ <mode>view</mode>
+ <mode>edit</mode>
+ <mode>help</mode>
</supports>
<portlet-info>
- <title>Simplest Hello World Portlet</title>
+ <title>JSP Hello User Portlet</title>
</portlet-info>
</portlet>
</portlet-app>
\ No newline at end of file
Added: examples/trunk/JSPHelloUser/src/main/webapp/jsp/edit.jsp
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/jsp/edit.jsp (rev
0)
+++ examples/trunk/JSPHelloUser/src/main/webapp/jsp/edit.jsp 2008-07-09 13:23:00 UTC (rev
11366)
@@ -0,0 +1,2 @@
+<div class="portlet-section-header">Edit mode</div>
+<div class='Portlet-section-body">This is the edit mode, a convenient
place to let the user change his portlet preferences.</div>
\ No newline at end of file
Added: examples/trunk/JSPHelloUser/src/main/webapp/jsp/hello.jsp
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/jsp/hello.jsp (rev
0)
+++ examples/trunk/JSPHelloUser/src/main/webapp/jsp/hello.jsp 2008-07-09 13:23:00 UTC (rev
11366)
@@ -0,0 +1,8 @@
+<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet"
%>
+<portlet:defineObjects/>
+
+<div class="portlet-section-header">Remember we love you: <%=
renderRequest.getParameter("yourname") %></div>
+
+<portlet:renderURL var="myRenderURL"/>
+<br/>
+<a href="<%= myRenderURL %>">Ask me again</a></div>
Added: examples/trunk/JSPHelloUser/src/main/webapp/jsp/help.jsp
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/jsp/help.jsp (rev
0)
+++ examples/trunk/JSPHelloUser/src/main/webapp/jsp/help.jsp 2008-07-09 13:23:00 UTC (rev
11366)
@@ -0,0 +1,2 @@
+<div class="portlet-section-header">Help mode</div>
+<div class='Portlet-section-body">This is the help mode, a convenient
place to give the user some help information.</div>
\ No newline at end of file
Added: examples/trunk/JSPHelloUser/src/main/webapp/jsp/welcome.jsp
===================================================================
--- examples/trunk/JSPHelloUser/src/main/webapp/jsp/welcome.jsp
(rev 0)
+++ examples/trunk/JSPHelloUser/src/main/webapp/jsp/welcome.jsp 2008-07-09 13:23:00 UTC
(rev 11366)
@@ -0,0 +1,35 @@
+<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet"
%>
+
+<div class="portlet-section-header">Welcome !</div>
+
+<br/>
+
+<div class="portlet-font">Welcome on the JSP Hello User portlet,
+my name is JBoss Portal. What's yours ?</div>
+
+<br/>
+
+<div class="portlet-font">Method 1: We simply pass the parameter to the
render phase:<br/>
+<a href="<portlet:renderURL><portlet:param name="yourname"
value="John Doe"/></portlet:renderURL>">John
Doe</a></div>
+
+<br/>
+
+<div class="portlet-font">Method 2: We pass the parameter to the render
phase, using valid XML:
+Please check the source code to see the difference with Method 1.
+<portlet:renderURL var="myRenderURL">
+ <portlet:param name="yourname" value='John Doe'/>
+</portlet:renderURL>
+<br/>
+<a href="<%= myRenderURL %>">John Doe</a></div>
+
+<br/>
+
+<div class="portlet-font">Method 3: We use a form:<br/>
+
+<portlet:actionURL var="myActionURL"/>
+<form action="<%= myActionURL %>" method="POST">
+ <span class="portlet-form-field-label">Name:</span>
+ <input class="portlet-form-input-field" type="text"
name="yourname"/>
+ <input class="portlet-form-button" type="Submit"/>
+</form>
+</div>
\ No newline at end of file