diff options
3 files changed, 92 insertions, 187 deletions
diff --git a/WebContent/WEB-INF/portlet.xml b/WebContent/WEB-INF/portlet.xml index b1a6d4722d..bab08d4eb1 100644 --- a/WebContent/WEB-INF/portlet.xml +++ b/WebContent/WEB-INF/portlet.xml @@ -2,7 +2,7 @@ <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> @@ -120,7 +120,7 @@ <role-name>user</role-name> </security-role-ref> </portlet> - + <portlet> <portlet-name>HelloWorldPortlet</portlet-name> <display-name>Hello World</display-name> @@ -136,92 +136,75 @@ <portlet-info> <title>HelloWorld</title> <short-title>HelloWorld</short-title> - </portlet-info> + </portlet-info> </portlet> - <!-- - <portlet> - <portlet-name>VaadinInterPortletEventPortlet</portlet-name> + <!-- + <portlet> <portlet-name>VaadinInterPortletEventPortlet</portlet-name> <display-name>Hello World Event</display-name> <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class> - <init-param> - <name>application</name> - <value>com.vaadin.demo.portlet.VaadinInterPortletEventPortlet</value> - </init-param> - <init-param> - <name>widgetset</name> - <value>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</value> - </init-param> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - </supports> - <portlet-info> - <title>Inter-portlet events</title> - <short-title>Inter-portlet events</short-title> - </portlet-info> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> - </supported-processing-event> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> - </supported-processing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> - </supported-publishing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> + <init-param> <name>application</name> + <value>com.vaadin.demo.portlet.VaadinInterPortletEventPortlet</value> + </init-param> <init-param> <name>widgetset</name> + <value>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</value> + </init-param> <supports> <mime-type>text/html</mime-type> + <portlet-mode>view</portlet-mode> </supports> <portlet-info> + <title>Inter-portlet events</title> <short-title>Inter-portlet + events</short-title> </portlet-info> <supported-processing-event> + <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> + </supported-processing-event> <supported-processing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> + </supported-processing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> + </supported-publishing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> </supported-publishing-event> - <supported-public-render-parameter>HelloState</supported-public-render-parameter> - </portlet> - - <portlet> + <supported-public-render-parameter>HelloState</supported-public-render-parameter> + </portlet> <portlet> <portlet-name>InterPortletEventPortlet</portlet-name> <display-name>Hello World Event (non-Vaadin)</display-name> <portlet-class>com.vaadin.demo.portlet.InterPortletEventPortlet</portlet-class> + <supports> <mime-type>text/html</mime-type> + <portlet-mode>view</portlet-mode> </supports> <portlet-info> + <title>Inter-portlet events (non-Vaadin)</title> + <short-title>Inter-portlet events (non-Vaadin)</short-title> + </portlet-info> <supported-processing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> + </supported-processing-event> <supported-processing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> + </supported-processing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> + </supported-publishing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> + </supported-publishing-event> + <supported-public-render-parameter>HelloState</supported-public-render-parameter> + </portlet> + --> + <portlet> + <portlet-name>Portlet Mode Example</portlet-name> + <display-name>Portlet Mode Example</display-name> + <portlet-class>com.vaadin.demo.portlet.PortletModePortlet</portlet-class> + <init-param> + <name>widgetset</name> + <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> + </init-param> + <init-param> + <name>application</name> + <value>com.vaadin.demo.portlet.PortletModeExample</value> + </init-param> + <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> + <portlet-mode>edit</portlet-mode> + <portlet-mode>help</portlet-mode> + <portlet-mode>config</portlet-mode> </supports> <portlet-info> - <title>Inter-portlet events (non-Vaadin)</title> - <short-title>Inter-portlet events (non-Vaadin)</short-title> + <title>PortletModeExample</title> + <short-title>PortletModeExample</short-title> </portlet-info> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> - </supported-processing-event> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> - </supported-processing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> - </supported-publishing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> - </supported-publishing-event> - <supported-public-render-parameter>HelloState</supported-public-render-parameter> </portlet> - --> - <portlet> - <portlet-name>Portlet Mode Example</portlet-name> - <display-name>Portlet Mode Example</display-name> - <portlet-class>com.vaadin.demo.portlet.PortletModePortlet</portlet-class> - <init-param> - <name>widgetset</name> - <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> - </init-param> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - <portlet-mode>edit</portlet-mode> - <portlet-mode>help</portlet-mode> - <portlet-mode>config</portlet-mode> - </supports> - <portlet-info> - <title>PortletModeExample</title> - <short-title>PortletModeExample</short-title> - </portlet-info> - </portlet> <portlet> <portlet-name>AddressBookPortlet</portlet-name> @@ -238,9 +221,9 @@ <portlet-info> <title>Address Book</title> <short-title>Address Book</short-title> - </portlet-info> - </portlet> - + </portlet-info> + </portlet> + <portlet> <portlet-name>SamplerPortlet</portlet-name> <display-name>Sampler</display-name> @@ -260,9 +243,9 @@ <portlet-info> <title>Sampler</title> <short-title>Sampler</short-title> - </portlet-info> + </portlet-info> </portlet> - + <portlet> <portlet-name>CalcPortlet</portlet-name> <display-name>Calc</display-name> @@ -274,7 +257,7 @@ <init-param> <name>widgetset</name> <value>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</value> - </init-param> + </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> @@ -282,8 +265,8 @@ <portlet-info> <title>Calc</title> <short-title>Calc</short-title> - </portlet-info> - </portlet> + </portlet-info> + </portlet> <portlet> <portlet-name>ChatServletPortlet</portlet-name> <display-name>Vaadin ChatServlet</display-name> @@ -361,23 +344,23 @@ <role-name>user</role-name> </security-role-ref> </portlet> - + <!-- Used by the Portlet mode demo --> - <custom-portlet-mode> - <description>Custom mode</description> - <portlet-mode>config</portlet-mode> - <portal-managed>false</portal-managed> - </custom-portlet-mode> + <custom-portlet-mode> + <description>Custom mode</description> + <portlet-mode>config</portlet-mode> + <portal-managed>false</portal-managed> + </custom-portlet-mode> <!-- - These can be used to customize the event object types. - The types must be serializable and have JAXB binding. + These can be used to customize the event object types. The types must + be serializable and have JAXB binding. --> <event-definition> <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> <value-type>java.lang.String</value-type> - </event-definition> - + </event-definition> + <event-definition> <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> <value-type>java.lang.String</value-type> @@ -387,7 +370,7 @@ <identifier>HelloState</identifier> <qname xmlns:vaadin="http://www.vaadin.com/params">vaadin:HelloState</qname> </public-render-parameter> - + <!-- This can be used to work around an issue in liferay 5.0-5.1.1 diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 428a9b38b9..680cf0709a 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -28,12 +28,10 @@ import javax.portlet.PortalContext; import javax.portlet.PortletConfig; import javax.portlet.PortletContext; import javax.portlet.PortletException; -import javax.portlet.PortletMode; import javax.portlet.PortletRequest; import javax.portlet.PortletResponse; import javax.portlet.PortletSession; import javax.portlet.PortletURL; -import javax.portlet.RenderMode; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.ResourceRequest; @@ -426,7 +424,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet /* * Always use the main window when running inside a portlet. */ - Window window = getPortletWindow(request, application); + Window window = application.getMainWindow(); if (window == null) { throw new PortletException(ERROR_NO_WINDOW_FOUND); } @@ -494,28 +492,6 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } - /** - * Returns a window for a portlet mode. To define custom content for a - * portlet mode, add (in the application) a window whose name matches the - * portlet mode name. By default, the main window is returned. - * - * Alternatively, a PortletListener can change the main window content. - * - * @param request - * @param application - * @return Window to show in the portlet for the given portlet mode - */ - protected Window getPortletWindow(PortletRequest request, - Application application) { - PortletMode mode = request.getPortletMode(); - Window window = application.getWindow(mode.toString()); - if (window != null) { - return window; - } - // no specific window found - return application.getMainWindow(); - } - private void updateBrowserProperties(WebBrowser browser, PortletRequest request) { browser.updateBrowserProperties(request.getLocale(), null, request @@ -648,53 +624,26 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet handleRequest(request, response); } - /** - * Handles a request for the "view" (default) portlet mode. In Vaadin, the - * basic portlet modes ("view", "edit" and "help") are handled identically, - * and their behavior can be changed by registering windows in the - * application with window names identical to the portlet mode names. - * Alternatively, a PortletListener can change the application main window - * contents. - * - * To implement custom portlet modes, subclass the portlet class and - * implement a method annotated with {@link RenderMode} for the custom mode, - * calling {@link #handleRequest(PortletRequest, PortletResponse)} directly - * from it. - * - * Note that the portlet class in the portlet configuration needs to be - * changed when overriding methods of this class. - * - * @param request - * @param response - * @throws PortletException - * @throws IOException - */ @Override - protected void doView(RenderRequest request, RenderResponse response) + protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException { - handleRequest(request, response); - } + try { + // try to let super handle - it'll call methods annotated for + // handling, the default doXYZ(), or throw if a handler for the mode + // is not found + super.doDispatch(request, response); - /** - * Handle a request for the "edit" portlet mode. - * - * @see #doView(RenderRequest, RenderResponse) - */ - @Override - protected void doEdit(RenderRequest request, RenderResponse response) - throws PortletException, IOException { - handleRequest(request, response); - } + } catch (PortletException e) { + if (e.getCause() == null) { + // No cause interpreted as 'unknown mode' - pass that trough + // so that the application can handle + handleRequest(request, response); - /** - * Handle a request for the "help" portlet mode. - * - * @see #doView(RenderRequest, RenderResponse) - */ - @Override - protected void doHelp(RenderRequest request, RenderResponse response) - throws PortletException, IOException { - handleRequest(request, response); + } else { + // Something else failed, pass on + throw e; + } + } } @Override diff --git a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index 3a5cd90f7c..0a3307fbb0 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -165,19 +165,6 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { + themeName + "/" + resource); } - /** - * Find the application window to use based on the portlet mode. For - * internal use only, not in the {@link Callback} interface. - * - * @param request - * @param application - * @return - */ - public Window getPortletWindow(PortletRequest request, - Application application) { - return portlet.getPortletWindow(request, application); - } - } public PortletCommunicationManager(Application application) { @@ -237,18 +224,4 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { new AbstractApplicationPortletWrapper(applicationPortlet)); } - @Override - protected Window doGetApplicationWindow(Request request, Callback callback, - Application application, Window assumedWindow) { - // find window based on portlet mode - if (assumedWindow == null - && callback instanceof AbstractApplicationPortletWrapper - && request.getWrappedRequest() instanceof PortletRequest) { - assumedWindow = ((AbstractApplicationPortletWrapper) callback) - .getPortletWindow((PortletRequest) request - .getWrappedRequest(), application); - } - return super.doGetApplicationWindow(request, callback, application, - assumedWindow); - } } |