Search code examples
gwtcheckboxhandlersetvaluevaluechangelistener

gwt checkbox fire handler when setValue(true)


I have a checkbox with a valueChangeHandler on it. It works when user check the checkbox.

For some reason, I need to set a value to this checkbox in my code, like this :

checkbox.setValue(true), the checkbox is perfectly checked visually but my problem is that it doesn't fire my valueChangeHandler.

checkBox.setValue(true);

checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
   @Override
   public void onValueChange(ValueChangeEvent<Boolean> event) {
     ...
   }
});

Is there another handler that can be fire when I set a value ? Or another way to dot this?

Thanks

EDIT : I also tried checkbox.setValue(true,true) but it doesn't work.

RESOLVED : the setValue MUST BE after the registration of the handler. Thanks


Solution

  • That's the difference between setValue(Boolean) vs. setValue(Boolean,boolean)

    checkBox.setValue(true, true);