Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Validation in textfield
we are begining in Vaadin and we are found a problem validating numbers.
A field is limited by bbdd to 10 digits.
First, if I define a variable in a dto as:
@Digits(integer = 9, fraction = 0)
private Integer kilometro;
when I add this component to layout it let introduce up to 10 digits instead of 9. Why? is there other way?
The other thing is: if I introduce this number as 3.125, the point is counted as a digit, so the component doesn't let you really 9 digits, but one less.
I think Vaadin don't by default interpert @Digits into any rules on client side. The validation is done on the server side using the bean validation library of your choice.
When the validation actually happens depends on your Vaadin version or the add-ons you use. With Vaadin 8 or with Viritin add-on you can make the validation happen practically instantly (my suggestion for great UX).
Maybe the text field is just exactly 10 chars long by default? You can also limit the client side input elements limit with setMaxLength method, but you'd probably need to adjust that value dynamically whether your user has typed in the dot or not.
Let me think about.
Thank you so much for your help