Validation problem

I want to validate my form, and I can’t understand how validation works.

I have sth like this:

actSchTimes = new OptionGroup(); 

	actSchTimes.addValidator(new OptionGroupNullValidator("erroren"));

so checkbox group with 2 items and the rule is that at least one must be selected. I made my own validator, he checks if there are any values

public class OptionGroupNullValidator extends AbstractValidator {

	public OptionGroupNullValidator(String errorMessage) {
		// TODO Auto-generated constructor stub

	public boolean isValid(Object value) {
		if(value != null){
			Set set = (Set) value;
			if(set.size() > 0){
				return true;
		return false;


when sth is selected output shows, but when I deselect all it seems that validator isn’t invoked. I don’t know what is wrong

You should use setRequired(true) on your field. If the field is empty the validators won’t be used, instead the required flag is checked and if the field is required, the requiredError message is shown, if the field is not required, everything is assumed to be ok and no error is shown. This is something that we are thinking about changing for Vaadin 7 (