Hi,
could anybody clarify finally the "circular reference" issue?
Let's say we are creating our own widget by extending Composite
public class ExampleItem extends Composite implements ClickHandler,
HasClickHandlers {
Grid grid;
Label label;
MyWidget myWidget;
public ExampleItem() {
grid = new Grid(1, 2);
...
ClickHandler labelHandler = label.addClickHandler(this);
ClickHandler myWidgetHandler = myWidget.addClickHandler(this);
ClickHandler thisHandler = addClickHandler(this);
initWidget(grid);
}
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addDomHandler(handler, ClickEvent.getType());
}
public void onClick(ClickEvent arg0) {
GWT.log("Click event", null);
}
}
Is in this case necessary to register/unregister any of the event
handlers in onLoad/onUnload
methods to avoid circular references/memory leaks? I checked the
source code of Widget component and
there is something what looks like it takes care about registering/
unregistering the handlers.
My current opinion is that only when I register an event listener by
calling DOM.setEventListener(element, listener)
instead of addDOMHandler() method then I should take care of
registering/unregistering of the listener in onLoad/onUnload methods.
And I also think that the same would be valid if extended Widget
instead of Composite.
Is that right? Do not hesitate and correct me, I have seen many
examples where people scared by the
widget-best-practices-widget-building article registered and
unregistered all handlers just to avoid possible memory leaks.
I don't wanna be a sheep in a flock without reason.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---