Showcase Start Screen "Data Binding" CheckboxItem validation issue

Hello,

I discovered a problem with CheckboxItem validation in version 2.4.
When you tick then untick and afterwards validate, the checkbox still tells true.
For proof I tried the showcase here: http://www.smartclient.com/smartgwt/showcase/#layout_form_databinding and its the same happening no matter if using IE or Firefox. Please help. Thanks.

SmartGWT 2.4, Firefox or IE does not matter

What is actually happening is that the field (accept checkbox) is set to required which means the user must place a value there. Once the user checks the box (or unchecks it) the field has a value. It may be true or false but it still has a value and thus passes validation. A “required” checkbox does not mean that the box must be checked to be valid. You must use a different validator to enforce that rule.

This sample should be updated with a validator that requires the box to be checked to meet the expected result.

Hi david,

thanks for your hint!!
Even though its not logic - my opinion - here is the solution if you need a checkbox being ticked in terms of required:

DynamicForm form = new DynamicForm();
CheckboxItem check = new CheckboxItem();
check.setRequired(true);
check.setValidators(new CustomValidator() {

@Override
protected boolean condition(Object value) {
return (Boolean) (value == null ? false : value);
}
});
form.setFields(check);

Then just call when the form is submitted:
form.validate(false);

Cheers
~limubai

Here is another solution.

CheckboxItem checkboxItem = new CheckboxItem();

checkboxItem.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {

			if (checkboxItem.getValueAsBoolean()) 
                                checkboxItem.clearValue();
				}

}