struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1201876 - in /struts/struts2/trunk/apps/portlet/src/main: java/org/apache/struts2/portlet/example/eventing/ resources/ webapp/WEB-INF/ webapp/WEB-INF/eventing/
Date Mon, 14 Nov 2011 20:24:57 GMT
Author: jogep
Date: Mon Nov 14 20:24:57 2011
New Revision: 1201876

URL: http://svn.apache.org/viewvc?rev=1201876&view=rev
Log:
WW-3707: Extend the Portlet Showcase with an Portlet Event Example

Added:
    struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/
    struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/ProcessAction.java
    struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/PublishAction.java
    struts/struts2/trunk/apps/portlet/src/main/resources/struts-eventing.xml
    struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/
    struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/index.jsp
    struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/process.jsp
Modified:
    struts/struts2/trunk/apps/portlet/src/main/resources/struts.xml
    struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/portlet.xml

Added: struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/ProcessAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/ProcessAction.java?rev=1201876&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/ProcessAction.java
(added)
+++ struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/ProcessAction.java
Mon Nov 14 20:24:57 2011
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.portlet.example.eventing;
+
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.portlet.interceptor.PortletRequestAware;
+import org.apache.struts2.portlet.interceptor.PortletResponseAware;
+
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+
+public class ProcessAction extends ActionSupport implements PortletRequestAware, PortletResponseAware
{
+
+    private PortletRequest request;
+    private PortletResponse response;
+    private String name;
+
+    public String execute() throws Exception {
+
+        if (request instanceof EventRequest) {
+            EventRequest req = (EventRequest) request;
+            EventResponse res = (EventResponse) response;
+            res.setRenderParameter("eventName", (String) req.getEvent().getValue());
+            return "forward";
+        } else {
+            name = request.getParameter("eventName");
+        }
+
+        return SUCCESS;
+    }
+
+    public void setPortletRequest(PortletRequest request) {
+        this.request = request;
+    }
+
+    public void setPortletResponse(PortletResponse response) {
+        this.response = response;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+}

Added: struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/PublishAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/PublishAction.java?rev=1201876&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/PublishAction.java
(added)
+++ struts/struts2/trunk/apps/portlet/src/main/java/org/apache/struts2/portlet/example/eventing/PublishAction.java
Mon Nov 14 20:24:57 2011
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.portlet.example.eventing;
+
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.portlet.interceptor.PortletResponseAware;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletResponse;
+import javax.xml.namespace.QName;
+
+public class PublishAction extends ActionSupport implements PortletResponseAware {
+
+    private PortletResponse response;
+    private String name;
+
+    public String execute() throws Exception {
+
+        if (name != null) {
+            ((ActionResponse) response).setEvent(new QName("http://org.apache.struts2.portlets/events",
"name"), name);
+
+            addActionMessage("Publishing Event with Parameter name : " + name);
+        }
+
+        return SUCCESS;
+    }
+
+    public void setPortletResponse(PortletResponse response) {
+        this.response = response;
+
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Added: struts/struts2/trunk/apps/portlet/src/main/resources/struts-eventing.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/resources/struts-eventing.xml?rev=1201876&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/resources/struts-eventing.xml (added)
+++ struts/struts2/trunk/apps/portlet/src/main/resources/struts-eventing.xml Mon Nov 14 20:24:57
2011
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE struts PUBLIC
+        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+        "http://struts.apache.org/dtds/struts-2.0.dtd">
+
+<struts>
+    <package name="eventing" extends="struts-portlet-default" namespace="/eventing">
+
+        <action name="publish" class="org.apache.struts2.portlet.example.eventing.PublishAction">
+            <result name="success">/WEB-INF/eventing/index.jsp</result>
+        </action>
+
+        <action name="process" class="org.apache.struts2.portlet.example.eventing.ProcessAction">
+            <result name="success">/WEB-INF/eventing/process.jsp</result>
+            <result name="forward" type="redirectAction">
+                <param name="actionName">process</param>
+                <param name="namespace">/eventing</param>
+            </result>
+        </action>
+    </package>
+</struts>

Modified: struts/struts2/trunk/apps/portlet/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/resources/struts.xml?rev=1201876&r1=1201875&r2=1201876&view=diff
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/resources/struts.xml (original)
+++ struts/struts2/trunk/apps/portlet/src/main/resources/struts.xml Mon Nov 14 20:24:57 2011
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE struts PUBLIC
-    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
-    "http://struts.apache.org/dtds/struts-2.0.dtd">
+        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+        "http://struts.apache.org/dtds/struts-2.0.dtd">
 
 <struts>
-	<include file="struts-view.xml"/>
-	<include file="struts-edit.xml"/>
-	<include file="struts-help.xml"/>
+    <include file="struts-view.xml"/>
+    <include file="struts-edit.xml"/>
+    <include file="struts-help.xml"/>
+    <include file="struts-eventing.xml"/>
 </struts>

Added: struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/index.jsp?rev=1201876&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/index.jsp (added)
+++ struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/index.jsp Mon Nov 14
20:24:57 2011
@@ -0,0 +1,11 @@
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<h2>Input your name</h2>
+
+<s:actionmessage/>
+
+<s:form action="publish" method="POST">
+    <s:textfield label="Please enter your name" name="name" value="%{name}"/>
+    <s:submit value="Submit the form"/>
+</s:form>
+

Added: struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/process.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/process.jsp?rev=1201876&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/process.jsp (added)
+++ struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/eventing/process.jsp Mon Nov
14 20:24:57 2011
@@ -0,0 +1,12 @@
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:if test="%{name != null}">
+    <h2>Welcome <s:property value="name"/></h2>
+</s:if>
+<s:else>
+    <h2>Please insert a Name in the Publish Portlet Form</h2>
+</s:else>
+
+<s:actionmessage/>
+
+

Modified: struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/portlet.xml?rev=1201876&r1=1201875&r2=1201876&view=diff
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/portlet.xml (original)
+++ struts/struts2/trunk/apps/portlet/src/main/webapp/WEB-INF/portlet.xml Mon Nov 14 20:24:57
2011
@@ -1,17 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <portlet-app
-    version="1.0"
-    xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
-    id="struts-portlet">
+        id="struts-portlet"
+        xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        version="2.0"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+        >
 
     <portlet id="StrutsPortlet">
         <description xml:lang="EN">Struts Test Portlet</description>
         <portlet-name>StrutsPortlet</portlet-name>
         <display-name xml:lang="EN">Struts Test Portlet</display-name>
-    
+
         <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
 
         <!-- The view mode namespace. Maps to a namespace in the Struts 2 config file.
-->
@@ -49,12 +50,12 @@
             <name>defaultHelpAction</name>
             <value>index</value>
         </init-param>
-    
+
         <expiration-cache>0</expiration-cache>
 
         <supports>
             <mime-type>text/html</mime-type>
-			<portlet-mode>view</portlet-mode>
+            <portlet-mode>view</portlet-mode>
             <portlet-mode>edit</portlet-mode>
             <portlet-mode>help</portlet-mode>
         </supports>
@@ -62,17 +63,17 @@
         <supported-locale>en</supported-locale>
 
         <portlet-info>
-            <title>My StrutsPortlet portlet</title>
-            <short-title>SP</short-title>
+            <title>My Struts2 Portlet</title>
+            <short-title>SP2</short-title>
             <keywords>struts,portlet</keywords>
         </portlet-info>
     </portlet>
-  
+
     <portlet id="StrutsPortlet2">
-        <description xml:lang="EN">Struts Test Portlet2</description>
+        <description xml:lang="EN">Struts Test Portlet with JSR 286 Dispatcher</description>
         <portlet-name>StrutsPortlet2</portlet-name>
-        <display-name xml:lang="EN">Struts Test Portlet2</display-name>
-    
+        <display-name xml:lang="EN">Struts Test Portlet with JSR 286 Dispatcher</display-name>
+
         <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
 
         <!-- The view mode namespace. Maps to a namespace in the Struts 2 config file.
-->
@@ -122,10 +123,92 @@
         <supported-locale>en</supported-locale>
 
         <portlet-info>
-            <title>My StrutsPortlet portlet2</title>
-            <short-title>SP2</short-title>
+            <title>My Struts2 Portlet with JSR 286 Dispatcher</title>
+            <short-title>SP2JSR286</short-title>
             <keywords>struts,portlet</keywords>
         </portlet-info>
     </portlet>
 
+
+    <portlet id="Struts2PublishPortlet">
+        <description xml:lang="EN">Struts2 Publish Portlet</description>
+        <portlet-name>Struts2PublishPortlet</portlet-name>
+        <display-name xml:lang="EN">Struts2 Publish Portlet</display-name>
+
+        <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
+
+        <!-- The view mode namespace. Maps to a namespace in the Struts 2 config file.
-->
+        <init-param>
+            <name>viewNamespace</name>
+            <value>/eventing</value>
+        </init-param>
+
+        <!-- The default action to invoke in view mode. -->
+        <init-param>
+            <name>defaultViewAction</name>
+            <value>publish</value>
+        </init-param>
+
+        <expiration-cache>0</expiration-cache>
+
+        <supports>
+            <mime-type>text/html</mime-type>
+        </supports>
+
+        <supported-locale>en</supported-locale>
+
+        <portlet-info>
+            <title>Struts2 Publish Portlet</title>
+            <short-title>S2PUB</short-title>
+            <keywords>struts,publish,portlet</keywords>
+        </portlet-info>
+
+        <supported-publishing-event xmlns:x="http://org.apache.struts2.portlets/events">
+            <qname>x:name</qname>
+        </supported-publishing-event>
+    </portlet>
+
+    <portlet id="Struts2ProcessPortlet">
+        <description xml:lang="EN">Struts2 Process Portlet</description>
+        <portlet-name>Struts2ProcessPortlet</portlet-name>
+        <display-name xml:lang="EN">Struts2 Process Portlet</display-name>
+
+        <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
+
+        <!-- The view mode namespace. Maps to a namespace in the Struts 2 config file.
-->
+        <init-param>
+            <name>viewNamespace</name>
+            <value>/eventing</value>
+        </init-param>
+
+        <!-- The default action to invoke in view mode. -->
+        <init-param>
+            <name>defaultViewAction</name>
+            <value>process</value>
+        </init-param>
+
+        <expiration-cache>0</expiration-cache>
+
+        <supports>
+            <mime-type>text/html</mime-type>
+        </supports>
+
+        <supported-locale>en</supported-locale>
+
+        <portlet-info>
+            <title>Struts2 Process Portlet</title>
+            <short-title>S2PRO</short-title>
+            <keywords>struts,process,portlet</keywords>
+        </portlet-info>
+
+        <supported-processing-event xmlns:x="http://org.apache.struts2.portlets/events">
+            <qname>x:name</qname>
+        </supported-processing-event>
+    </portlet>
+
+    <event-definition>
+        <qname xmlns:x="http://org.apache.struts2.portlets/events">x:name</qname>
+        <value-type>java.lang.String</value-type>
+    </event-definition>
+
 </portlet-app>



Mime
View raw message