From 06995b4714b5238c0da832165be8ea60c249738e Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Fri, 28 Aug 2009 14:04:38 +0000 Subject: [PATCH] Window-close XHR moved to onbeforeunload, AbstractApplicationServlet and CommunicationManager uses same logic to figure out Window name; fixes #3241 svn changeset:8581/svn branch:6.1 --- .../vaadin/terminal/gwt/client/ui/VView.java | 6 ++-- .../server/AbstractApplicationServlet.java | 31 ++++++------------- .../gwt/server/CommunicationManager.java | 8 +++-- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 98b64f7c72..a76f559c3e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -461,6 +461,10 @@ public class VView extends SimplePanel implements Container, }-*/; public void onWindowClosed() { + + } + + public String onWindowClosing() { // Change focus on this window in order to ensure that all state is // collected from textfields VTextField.flushChangesFromFocusedTextField(); @@ -468,9 +472,7 @@ public class VView extends SimplePanel implements Container, // Send the closing state to server connection.updateVariable(id, "close", true, false); connection.sendPendingVariableChangesSync(); - } - public String onWindowClosing() { return null; } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 0e1566ad0e..0640477e5c 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -433,7 +433,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet { } // Finds the window within the application - Window window = getApplicationWindow(request, application); + Window window = getApplicationWindow(request, applicationManager, + application); if (window == null) { throw new ServletException(ERROR_NO_WINDOW_FOUND); } @@ -1803,18 +1804,16 @@ public abstract class AbstractApplicationServlet extends HttpServlet { * servlet's normal operation. */ private Window getApplicationWindow(HttpServletRequest request, - Application application) throws ServletException { - - Window window = null; + CommunicationManager applicationManager, Application application) + throws ServletException { // Finds the window where the request is handled + Window assumedWindow = null; String path = getRequestPathInfo(request); // Main window as the URI is empty - if (path == null || path.length() == 0 || path.equals("/") - || path.startsWith("/APP/")) { - window = application.getMainWindow(); - } else { + if (!(path == null || path.length() == 0 || path.equals("/") || path + .startsWith("/APP/"))) { String windowName = null; if (path.charAt(0) == '/') { path = path.substring(1); @@ -1825,23 +1824,13 @@ public abstract class AbstractApplicationServlet extends HttpServlet { path = ""; } else { windowName = path.substring(0, index); - path = path.substring(index + 1); } - window = application.getWindow(windowName); - - if (window == null) { - // By default, we use main window - window = application.getMainWindow(); - } else if (!window.isVisible()) { - // Implicitly painting without actually invoking paint() - window.requestRepaintRequests(); + assumedWindow = application.getWindow(windowName); - // If the window is invisible send a blank page - return null; - } } - return window; + return applicationManager.getApplicationWindow(request, this, + application, assumedWindow); } String getRequestPathInfo(HttpServletRequest request) { diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index 75be657ef0..4971db4b8b 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -456,7 +456,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, invalidComponentRelativeSizes = ComponentSizeValidator .validateComponentRelativeSizes(w.getContent(), null, null); - + // Also check any existing subwindows if (w.getChildWindows() != null) { for (Window subWindow : (Set) w @@ -1036,7 +1036,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, * if an exception has occurred that interferes with the * servlet's normal operation. */ - private Window getApplicationWindow(HttpServletRequest request, + Window getApplicationWindow(HttpServletRequest request, AbstractApplicationServlet applicationServlet, Application application, Window assumedWindow) throws ServletException { @@ -1061,7 +1061,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // Get the path from URL String path = applicationServlet.getRequestPathInfo(request); - path = path.substring("/UIDL".length()); + if (path.startsWith("/UIDL")) { + path = path.substring("/UIDL".length()); + } // If the path is specified, create name from it if (path != null && path.length() > 0 && !path.equals("/")) { -- 2.39.5