diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/AbstractCommunicationManager.java | 21 | ||||
-rw-r--r-- | server/src/com/vaadin/server/Page.java | 4 |
2 files changed, 22 insertions, 3 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 43a9ced608..c3a6213265 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -61,6 +61,7 @@ import org.json.JSONException; import org.json.JSONObject; import com.vaadin.annotations.JavaScript; +import com.vaadin.annotations.PreserveOnRefresh; import com.vaadin.annotations.StyleSheet; import com.vaadin.server.ComponentSizeValidator.InvalidLayout; import com.vaadin.server.RpcManager.RpcInvocationException; @@ -2467,7 +2468,7 @@ public abstract class AbstractCommunicationManager implements Serializable { UI existingUi = legacyProvider .getExistingUI(classSelectionEvent); if (existingUi != null) { - UI.setCurrent(existingUi); + reinitUI(existingUi, request); return existingUi; } } @@ -2498,6 +2499,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (retainedUIId != null) { UI retainedUI = session.getUIById(retainedUIId.intValue()); if (uiClass.isInstance(retainedUI)) { + reinitUI(retainedUI, request); return retainedUI; } else { getLogger() @@ -2547,6 +2549,23 @@ public abstract class AbstractCommunicationManager implements Serializable { } /** + * Updates a UI that has already been initialized but is now loaded again, + * e.g. because of {@link PreserveOnRefresh}. + * + * @param ui + * @param request + */ + private void reinitUI(UI ui, VaadinRequest request) { + UI.setCurrent(ui); + + // Fire fragment change if the fragment has changed + String location = request.getParameter("loc"); + if (location != null) { + ui.getPage().updateLocation(location); + } + } + + /** * Generates the initial UIDL message that can e.g. be included in a html * page to avoid a separate round trip just for getting the UIDL. * diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index 1f4ff040ac..ab8c591b13 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -657,8 +657,8 @@ public class Page implements Serializable { String oldFragment = this.location.getFragment(); this.location = new URI(location); String newFragment = this.location.getFragment(); - if (newFragment == null && oldFragment != null - || !newFragment.equals(oldFragment)) { + if (newFragment == null ? oldFragment != null : !newFragment + .equals(oldFragment)) { fireEvent(new FragmentChangedEvent(this, newFragment)); } } catch (URISyntaxException e) { |