On 22 jan, 16:57, shahid <[email protected]> wrote:
> I am a little confused about event disposal in GWT. Should I always
> keep a reference to all HandlerRegistration objects whenever I attach
> a handler to something (e.g. image, links etc.) and then dispose them
> using .removeHandle upon widget detach ? Will not doing so end up in
> memory leak ? Or do the events get disposed of upon Widget detach
> automatically ?
If you attach your handlers in onAttach unconditionally,then you
should really remove them in onDetach. But you can also do the
following:
public void onAttach() {
if (isOrWasAttached()) {
// attach handlers
}
super.onAttach();
}
and then just simply do nothing in onDetach.
Or you can even attach your handlers before onAttach (e.g. on the
constructor), and never explicitly detach them.
GWT will take care of the rest, and particularly that there's no
memory leak.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.