summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-12-04 16:41:49 +0200
committerVaadin Code Review <review@vaadin.com>2012-12-07 08:48:06 +0000
commit50665cb1d34c84bc478cd5306f6c6151fe4d0bc3 (patch)
tree329772d20abe91f084980cc203fdeec046283620 /client
parentece1ab1fa500ad7142b80534dffee0b3883a984e (diff)
downloadvaadin-framework-50665cb1d34c84bc478cd5306f6c6151fe4d0bc3.tar.gz
vaadin-framework-50665cb1d34c84bc478cd5306f6c6151fe4d0bc3.zip
Reset state before sending hierarchy event to removed connector (#10151)
Change-Id: If4f3e23a1d58c9f1cec7fc7d5e4e3f470932162f
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 354d809622..5f90fe4c19 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -2035,6 +2035,31 @@ public class ApplicationConnection {
private void recursivelyDetach(ServerConnector connector,
List<ConnectorHierarchyChangeEvent> events) {
+
+ /*
+ * Reset state in an attempt to keep it consistent with the
+ * hierarchy. No children and no parent is the initial situation
+ * for the hierarchy, so changing the state to its initial value
+ * is the closest we can get without data from the server.
+ * #10151
+ */
+ try {
+ Type stateType = AbstractConnector.getStateType(connector);
+
+ // Empty state instance to get default property values from
+ Object defaultState = stateType.createInstance();
+
+ SharedState state = connector.getState();
+
+ for (Property property : stateType.getProperties()) {
+ property.setValue(state,
+ property.getValue(defaultState));
+ }
+ } catch (NoDataException e) {
+ throw new RuntimeException("Can't reset state for "
+ + Util.getConnectorString(connector), e);
+ }
+
/*
* Recursively detach children to make sure they get
* setParent(null) and hierarchy change events as needed.