Behaviour of Form and custom validator on DateField

Could not find a thread on this subject so I may as well start a new one.

Here is my problem.

I want to add a validator on a DateField within a form, This validator could check if the selected date is not a sunday (or a non working day for instance).

Here is the behaviour I have at the moment, when I click “submit” (which calls form.commit), the selected date (a sunday) makes the validator to launch an InvalidValueException in the “DateField.changeVariables”. So the exception is thrown after the “update form buffer” is done.

This has for effect to revert the field back to its old value.

Then the commit goes and the form is at this stage valid because of the “revert” done just before.

The consequence of all this is that the date field where the user selected a sunday is on the screen reverted back to previous value (the one before the user selected a sunday).

Would this be considered as
a) normal behaviour ?
b) bug with date field ?
c) I am missing something with the way validators and field are working.

would appreciate a bit of help here …

E.
11629.java (3.79 KB)

Just do yourValidatedField.setInvalidAllowed(true) to allow it to contain invalid values. After that your example behaves as you expect. A good place to do so is in the same place where you add the validator.