Search code examples
javagwtuibinder

Getting HandlerRegistration of @UiHandler


I suppose the following code:

@UiHandler("button")
void click(ClickEvent event) {
   //do something
}

does something like

HandlerRegistration reg = button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
        //do something
    }
});

except it doesn't return HandlerRegistration object.

Is it possible to get HandlerRegistration object for the handler generated from UiBinder?

Is there any other way to remove such handler?


Solution

  • No.

    If you need to manage the lifecycle of the handler, you have to addClickHandler yourself and keep a handle on the returned HandlerRegistration.