From: Henri Sara Date: Thu, 1 Oct 2009 12:34:37 +0000 (+0000) Subject: #3381 A detached UriFragmentUtility should not send events X-Git-Tag: 6.7.0.beta1~2454^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3a42df25af513c2adceffc614ba134ae299f98c4;p=vaadin-framework.git #3381 A detached UriFragmentUtility should not send events svn changeset:9008/svn branch:6.1 --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUriFragmentUtility.java b/src/com/vaadin/terminal/gwt/client/ui/VUriFragmentUtility.java index c67de9aebf..f0d571e741 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VUriFragmentUtility.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VUriFragmentUtility.java @@ -3,6 +3,7 @@ package com.vaadin.terminal.gwt.client.ui; import com.google.gwt.dom.client.Document; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.History; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -13,7 +14,7 @@ import com.vaadin.terminal.gwt.client.UIDL; /** * Client side implementation for UriFragmentUtility. Uses GWT's History object * as an implementation. - * + * */ public class VUriFragmentUtility extends Widget implements Paintable, ValueChangeHandler { @@ -22,6 +23,7 @@ public class VUriFragmentUtility extends Widget implements Paintable, private ApplicationConnection client; private String paintableId; private boolean immediate; + private HandlerRegistration historyValueHandlerRegistration; public VUriFragmentUtility() { setElement(Document.get().createDivElement()); @@ -29,10 +31,21 @@ public class VUriFragmentUtility extends Widget implements Paintable, getElement().getStyle().setProperty("overflow", "hidden"); getElement().getStyle().setProperty("height", "0"); } - History.addValueChangeHandler(this); + } + + @Override + protected void onAttach() { + super.onAttach(); + historyValueHandlerRegistration = History.addValueChangeHandler(this); History.fireCurrentHistoryState(); } + @Override + protected void onDetach() { + super.onDetach(); + historyValueHandlerRegistration.removeHandler(); + } + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { if (client.updateComponent(this, uidl, false)) { return;