changing checkbox value without firing ValueChangeListeners

I would like to change the value of checkbox without firing the ValueChangeListeners.

Didn’t see anything obvious in the api. Possible? If yes, how?

checkbox.setValue(true);

Sorry, meant to say that you have to remove the value change listeners before setting the value (using setValue()) if you don’t want them to fire. Another option is to use a flag in your class and keep track of if you should react to the value change event or not

I can’t see any way to enumerate the listeners in checkbox, so remove-before-add-after is not an option.

So, there’s no built in way to do this. :frowning:

Nope, changing the value will change the value, thus triggering the ValueChange listeners.

You will have to do some coding; exactly what would be appripriate depends on your particular case.
Perhaps you could extend CheckBox and use setInternalValue()? Something like

class MyCheckBox extends CheckBox {
        public void setValueSeceretly(boolean value) {
            this.setInternalValue(new Boolean(value));
        }
    }

…though I have not tried it…

Best Regards,
Marc

Seems to work.


public void setValueSecretly(Object newValue)
{
  setInternalValue(newValue);
  requestRepaint();
}

Thanks for pointing that out.