From f3f5f0ebff01df7aa22177629bbac45d4e157243 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Fri, 13 Jan 2012 12:14:00 +0000 Subject: [PATCH] #8241 Rename Vaadin-Redirect to Vaadin-Refresh, make URI optional: if not given, refresh the current page svn changeset:22625/svn branch:6.7 --- .../gwt/client/ApplicationConnection.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 88f55bf24b..0bb311600c 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -97,9 +97,9 @@ public class ApplicationConnection { public static final String ATTRIBUTE_ERROR = "error"; /** - * A string that, if found in a non-JSON response to a UIDL request, - * followed by a colon, optional whitespace, and a URI, will cause the - * browser to synchronously load the URI. + * A string that, if found in a non-JSON response to a UIDL request, will + * cause the browser to refresh the page. If followed by a colon, optional + * whitespace, and a URI, causes the browser to synchronously load the URI. * *

* This allows, for instance, a servlet filter to redirect the application @@ -110,12 +110,12 @@ public class ApplicationConnection { * if (sessionExpired) { * response.setHeader("Content-Type", "text/html"); * response.getWriter().write( - * myLoginPageHtml + "<!-- Vaadin-Redirect: " + * myLoginPageHtml + "<!-- Vaadin-Refresh: " * + request.getContextPath() + " -->"); * } * */ - public static final String UIDL_REDIRECT_TOKEN = "Vaadin-Redirect"; + public static final String UIDL_REFRESH_TOKEN = "Vaadin-Refresh"; // will hold the UIDL security key (for XSS protection) once received private String uidlSecurityKey = "init"; @@ -544,13 +544,15 @@ public class ApplicationConnection { * the request and served non-UIDL content (for * instance, a login page if the session has expired.) * If the response contains a magic substring, do a - * synchronous redirect to the given URI. See #8241 + * synchronous refresh. */ - MatchResult redirectUri = RegExp.compile( - UIDL_REDIRECT_TOKEN + ":\\s*(.*?)(\\s|$)") + MatchResult refreshToken = RegExp.compile( + UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)") .exec(response.getText()); - if (redirectUri != null) { - redirect(redirectUri.getGroup(1)); + if (refreshToken != null) { + redirect(refreshToken.getGroup(2)); + VConsole.log("*** REDIRECT : " + + refreshToken.getGroup(2)); return; } } -- 2.39.5