Datefield.validate()

I have a datefield like this:


Datefield ends.addValidator(new DateRangeValidator("Some text.",
                                                     date.getTime(),
                                                     null,
                                                     Resolution.DAY));

If I validate this field with ends,validate() the error message will be “Date format not recognized” because of this code in DateField.class. currentParseErrorMessage has the default value


    @Override
    public void validate() throws InvalidValueException {
        /*
         * To work properly in form we must throw exception if there is
         * currently a parsing error in the datefield. Parsing error is kind of
         * an internal validator.
         */
        if (!uiHasValidDateString) {
            throw new UnparsableDateString(currentParseErrorMessage);
        }
        super.validate();
    }

Is this the right behavior? If the value of the field is not valid my validator in super.validate() would not be called. In there a way to show “Some text” when validation fails?

BTW: The DateRangeValidator constructor has a parameter Resolution that is not used within the constructor and is not mentioned in javadoc

any ideas?

com.vaadin.ui.DateField.setParseErrorMessage(String)

Yeah, DateRangeValidator only validates that an already-parsed date is within the given bounds. BTW, you should use setRangeEnd() instead of explicitly adding a DateRangeValidator so that the range is shown in the UI - you can set its validation message with setDateOutOfRangeMessage().