]> source.dussan.org Git - vaadin-framework.git/commitdiff
Preliminary support for portlet events.
authorPetter Holmström <petter.holmstrom@itmill.com>
Tue, 10 Nov 2009 12:21:09 +0000 (12:21 +0000)
committerPetter Holmström <petter.holmstrom@itmill.com>
Tue, 10 Nov 2009 12:21:09 +0000 (12:21 +0000)
svn changeset:9708/svn branch:portlet_2.0

WebContent/WEB-INF/liferay-display.xml
WebContent/WEB-INF/portlet.xml
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java

index 288a4638c1300c117cd03cc2cd2897bdac0ce413..2981e08fd456ce703d77c494c890276df537b9d4 100644 (file)
@@ -18,5 +18,6 @@
                                <portlet id="AddressBookPortlet" />
                                <portlet id="CalcPortlet"/>
                                <portlet id="SamplerPortlet"/>
+                               <portlet id="HelloWorldEventPortlet"/>
         </category>
 </display>
\ No newline at end of file
index f097509c870800144457d95c0a6fa68ad2349cdb..d05e88e8d770e35a4a6b33503cdda7f930790068 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
-       version="1.0" 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">
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+       version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       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>
                <portlet-name>PortletDemoPortlet</portlet-name>
                <display-name>Vaadin PortletDemo</display-name>
                        <role-name>user</role-name>
                </security-role-ref>
        </portlet>
+       
        <portlet>
                <portlet-name>HelloWorldPortlet</portlet-name>
                <display-name>Hello World</display-name>
                        <title>HelloWorld</title>
                        <short-title>HelloWorld</short-title>
                </portlet-info>         
+               <supported-processing-event>
+               <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname>
+               </supported-processing-event>
+               <supported-publishing-event>
+               <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname>
+               </supported-publishing-event>
        </portlet>
+       
+       <portlet>
+               <portlet-name>HelloWorldEventPortlet</portlet-name>
+               <display-name>Hello World Event (non-Vaadin)</display-name>
+               <portlet-class>com.vaadin.demo.HelloWorldEventPortlet</portlet-class>
+               <supports>
+                       <mime-type>text/html</mime-type>
+                       <portlet-mode>view</portlet-mode>
+               </supports>
+               <portlet-info>
+                       <title>HelloWorldEvent (non-Vaadin)</title>
+                       <short-title>HelloWorldEvent (non-Vaadin)</short-title>
+               </portlet-info>
+               <supported-processing-event>
+               <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname>
+               </supported-processing-event>
+               <supported-publishing-event>
+               <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname>
+               </supported-publishing-event>
+       </portlet>
+
        <portlet>
                <portlet-name>AddressBookPortlet</portlet-name>
                <display-name>Address Book</display-name>
                        <role-name>user</role-name>
                </security-role-ref>
        </portlet>
+       
+       <event-definition>
+               <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname>
+               <value-type>java.lang.String</value-type>
+       </event-definition>     
+       
+       <event-definition>
+               <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname>
+               <value-type>java.lang.String</value-type>
+       </event-definition>
 
        <!--
                This can be used to work around an issue in liferay 5.0-5.1.1
index 6119c048e07a76e3bbdb15ddde6b547d45c22285..4dcc38d21d9aa0888b83b1d1cf8e0bf39460a055 100644 (file)
@@ -22,6 +22,9 @@ import java.util.Properties;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
+import javax.portlet.EventPortlet;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
 import javax.portlet.GenericPortlet;
 import javax.portlet.MimeResponse;
 import javax.portlet.PortletConfig;
@@ -255,7 +258,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
     }
 
     enum RequestType {
-        FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APPLICATION_RESOURCE, DUMMY, UNKNOWN;
+        FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APPLICATION_RESOURCE, DUMMY, EVENT, UNKNOWN;
     }
 
     protected RequestType getRequestType(PortletRequest request) {
@@ -275,6 +278,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
             if (isFileUploadRequest((ActionRequest) request)) {
                 return RequestType.FILE_UPLOAD;
             }
+        } else if (request instanceof EventRequest) {
+            return RequestType.EVENT;
         }
         return RequestType.UNKNOWN;
     }
@@ -310,18 +315,18 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
 
     protected void handleRequest(PortletRequest request,
             PortletResponse response) throws PortletException, IOException {
-        System.out.println("AbstractApplicationPortlet.handleRequest() "
-                + System.currentTimeMillis());
+//        System.out.println("AbstractApplicationPortlet.handleRequest() "
+//                + System.currentTimeMillis());
 
         RequestType requestType = getRequestType(request);
 
-        System.out.println("  RequestType: " + requestType);
-        System.out.println("  WindowID: " + request.getWindowID());
+//        System.out.println("  RequestType: " + requestType);
+//        System.out.println("  WindowID: " + request.getWindowID());
 
         if (requestType == RequestType.UNKNOWN) {
             System.err.println("Unknown request type");
         } else if (requestType == RequestType.DUMMY) {
-            System.out.println("Printing Dummy page");
+//            System.out.println("Printing Dummy page");
             /*
              * This dummy page is used by action responses to redirect to, in
              * order to prevent the boot strap code from being rendered into
@@ -400,6 +405,17 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
                             (ResourceRequest) request,
                             (ResourceResponse) response, this);
                     return;
+                } else if (requestType == RequestType.EVENT) {
+                    /*
+                     * Redirect portlet event to application if it implements
+                     * the EventPortlet interface (contains only one method).
+                     */
+                    // TODO Figure out a better way of handling events
+                    if (application instanceof EventPortlet) {
+                        ((EventPortlet) application).processEvent(
+                                (EventRequest) request,
+                                (EventResponse) response);
+                    }
                 } else {
                     /*
                      * Removes the application if it has stopped
@@ -468,6 +484,12 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
         }
     }
 
+    @Override
+    public void processEvent(EventRequest request, EventResponse response)
+            throws PortletException, IOException {
+        handleRequest(request, response);
+    }
+
     private boolean handleURI(PortletCommunicationManager applicationManager,
             Window window, ResourceRequest request, ResourceResponse response)
             throws IOException {