aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/Application.java
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2011-12-22 16:40:18 +0200
committerMarc Englund <marc@vaadin.com>2011-12-22 16:41:16 +0200
commit4291447dede525a31c38629254499b7b93812be3 (patch)
treea8596652aa3fd408cbb171ec50a154cabe306434 /src/com/vaadin/Application.java
parent959bd06303210e5c7fb63b35ddc839d3d419bbbc (diff)
downloadvaadin-framework-4291447dede525a31c38629254499b7b93812be3.tar.gz
vaadin-framework-4291447dede525a31c38629254499b7b93812be3.zip
Root preservation should now work, even with @EagerInit etc. Also if turned on in Root constructor or init(). Limitation: can not preserve roots that are already shown when preservation is turned on (this could be fixed in the future).
Diffstat (limited to 'src/com/vaadin/Application.java')
-rw-r--r--src/com/vaadin/Application.java48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index 9d38c72dcd..83084f4213 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -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();
+ }
}
/**