]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #8241: Provide a way to redirect the client to a given URI in a UIDL response...
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Thu, 12 Jan 2012 15:51:58 +0000 (15:51 +0000)
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Thu, 12 Jan 2012 15:51:58 +0000 (15:51 +0000)
svn changeset:22619/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ApplicationConnection.java

index 944d9b5974b5e2912b42ea7dcc7db79d70d6bb09..88f55bf24bbf7f16c944819ea4fed387d00e46de 100644 (file)
@@ -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, 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.
+     * 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.
      * 
      * <p>
      * This allows, for instance, a servlet filter to redirect the application
@@ -110,12 +110,12 @@ public class ApplicationConnection {
      * if (sessionExpired) {
      *     response.setHeader(&quot;Content-Type&quot;, &quot;text/html&quot;);
      *     response.getWriter().write(
-     *             myLoginPageHtml + &quot;&lt;!-- Vaadin-Refresh: &quot;
+     *             myLoginPageHtml + &quot;&lt;!-- Vaadin-Redirect: &quot;
      *                     + request.getContextPath() + &quot; --&gt;&quot;);
      * }
      * </pre>
      */
-    public static final String UIDL_REFRESH_TOKEN = "Vaadin-Refresh";
+    public static final String UIDL_REDIRECT_TOKEN = "Vaadin-Redirect";
 
     // will hold the UIDL security key (for XSS protection) once received
     private String uidlSecurityKey = "init";
@@ -544,13 +544,13 @@ 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 refresh. See #8241.
+                         * synchronous redirect to the given URI. See #8241
                          */
-                        MatchResult refreshToken = RegExp.compile(
-                                UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)")
+                        MatchResult redirectUri = RegExp.compile(
+                                UIDL_REDIRECT_TOKEN + ":\\s*(.*?)(\\s|$)")
                                 .exec(response.getText());
-                        if (refreshToken != null) {
-                            redirect(refreshToken.getGroup(2));
+                        if (redirectUri != null) {
+                            redirect(redirectUri.getGroup(1));
                             return;
                         }
                     }