Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Fails to get invalid and null values from DateField for custom validation

Rakesh C
10 years ago Feb 28, 2012 7:18am
Marcel Hallmann
10 years ago Feb 28, 2012 1:26pm
Rakesh C
10 years ago Feb 29, 2012 5:16am
Henri Sara
10 years ago Feb 29, 2012 8:00am

Rakesh Gowda: I have investigated for DateField in the form, if user enters invalid date / non date or string value, field.getValue() always return null which prohibits me in differentiate between validation for null or required field and validation for non date value inputs.

Take a look at DateField.handleUnparsableDateString(...). If it throws an exception, it is internally converted to a flag value in DateField.changeVariables(...) and used to throw another exception when DateField.validate() is called, so I believe you should get a validation exception in this case.

Anyhow i have used this but while displaying i should display instant / immediate custom error messages in header of the application instead of displaying error message in form error component.
Please suggest anymore way of getting values to my controller for custom validation.

Maybe someone else can give a better answer for this one, but as starting points you could take a look at AbstractComponent.setComponentError(...), AbstractField.setValidationVisible(...) and AbstractField.getErrorMessage().

Bobby Bissett
10 years ago Mar 06, 2012 2:56pm
Tommi Laukkanen
8 years ago Mar 03, 2014 2:31pm
Ed Tidwell
7 years ago Jul 30, 2014 8:38pm