aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2010-02-12 12:28:53 +0000
committerMarc Englund <marc.englund@itmill.com>2010-02-12 12:28:53 +0000
commitdea99fd63f72d205292cdbcda7f70cc2b49be6fd (patch)
tree24cef0ba2b1b674b2f688d4de5ebec8cb4985366 /src
parent7eea529f67c76b91869a1541287e66b151d6b7e1 (diff)
downloadvaadin-framework-dea99fd63f72d205292cdbcda7f70cc2b49be6fd.tar.gz
vaadin-framework-dea99fd63f72d205292cdbcda7f70cc2b49be6fd.zip
Merged portlet mode and windowing changes from 6.2. For #4143
svn changeset:11297/svn branch:6.3
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java85
-rw-r--r--src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java27
2 files changed, 17 insertions, 95 deletions
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);
- }
}