Monday, October 29, 2012

Re: Destroy a widget

When you create two HelloWorld widgets each of them receives its own events. If you use @UiHandler in your UiBinder widget and you want to stop receive events for a widget without removing the widget itself from the parent (for whatever reason) you have to "disable" your @UiHandler implementation.

So you would end up having

@UiHandler(...)
void onEvent(...) {
  if(handleEvents) {
     //do your event logic
  }
}

or you use a Delegate interface that a class can implement and that contains your event logic implementation:

@UiHandler(...)
void onEvent(...) {
  if(delegate != null) {
     delegate.onEvent();
  }
}

In that case you would disable your events by nulling your delegate: widget.setDelegate(null)


Otherwise you have to remove the widget from the parent.


-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/U0eTr0jdQ9wJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment