]> source.dussan.org Git - vaadin-framework.git/commitdiff
Root preservation should now work, even with @EagerInit etc. Also if turned on in...
authorMarc Englund <marc@vaadin.com>
Thu, 22 Dec 2011 14:40:18 +0000 (16:40 +0200)
committerMarc Englund <marc@vaadin.com>
Thu, 22 Dec 2011 14:41:16 +0000 (16:41 +0200)
src/com/vaadin/Application.java

index 9d38c72dcd1b8d9bd51506840818a07caf07604b..83084f42132381cf9fbea2c1746f500517a85cd7 100644 (file)
@@ -2227,25 +2227,22 @@ public class Application implements Terminal.ErrorListener, Serializable {
 
             root = roots.get(rootId);
 
-            boolean preserveRoot = isRootPreserved();
-
-            if (root == null && preserveRoot) {
+            if (root == null && isRootPreserved()) {
                 // Check for a known root
-                if (retainOnRefreshRoots.isEmpty()) {
-                    return null;
-                }
-
-                Integer retainedRootId;
-                if (!hasBrowserDetails) {
-                    throw new RootRequiresMoreInformationException();
-                } else {
-                    String windowName = browserDetails.getWindowName();
-                    retainedRootId = retainOnRefreshRoots.get(windowName);
-                }
+                if (!retainOnRefreshRoots.isEmpty()) {
+
+                    Integer retainedRootId;
+                    if (!hasBrowserDetails) {
+                        throw new RootRequiresMoreInformationException();
+                    } else {
+                        String windowName = browserDetails.getWindowName();
+                        retainedRootId = retainOnRefreshRoots.get(windowName);
+                    }
 
-                if (retainedRootId != null) {
-                    rootId = retainedRootId;
-                    root = roots.get(rootId);
+                    if (retainedRootId != null) {
+                        rootId = retainedRootId;
+                        root = roots.get(rootId);
+                    }
                 }
             }
 
@@ -2269,22 +2266,24 @@ public class Application implements Terminal.ErrorListener, Serializable {
             }
 
             if (!initedRoots.contains(rootId)) {
-                boolean initRequiresBrowserDetails = preserveRoot
+                boolean initRequiresBrowserDetails = isRootPreserved()
                         || !root.getClass()
                                 .isAnnotationPresent(EagerInit.class);
                 if (initRequiresBrowserDetails && !hasBrowserDetails) {
                     pendingRoots.put(rootId, new PendingRootRequest(request));
                 } else {
-                    if (preserveRoot) {
+                    root.doInit(request);
+
+                    // Remember that this root has been initialized
+                    initedRoots.add(rootId);
+
+                    // init() might turn on preserve so do this afterwards
+                    if (isRootPreserved()) {
                         // Remember this root
                         String windowName = request.getBrowserDetails()
                                 .getWindowName();
                         retainOnRefreshRoots.put(windowName, rootId);
                     }
-                    root.doInit(request);
-
-                    // Remember that this root has been initialized
-                    initedRoots.add(rootId);
                 }
             }
         } // end synchronized block
@@ -2327,6 +2326,9 @@ public class Application implements Terminal.ErrorListener, Serializable {
      */
     public void setRootPreserved(boolean rootPreserved) {
         this.rootPreserved = rootPreserved;
+        if (!rootPreserved) {
+            retainOnRefreshRoots.clear();
+        }
     }
 
     /**