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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to vaildate fields
Hi,
I have using vaadin technology i need validate combobox, radio button and textbox still now am using form validation in my application so please ow can i solve this issue if any idea let me know.
form.addField("select", select);
form.setComponentError(new UserError(e.getMessage()));
but i did not get the error msg in my ui ..
Please any idea let me know
thanks
karthik
try field.setImmediate(true) and also set the compoentError onto the field, not onto the form.
Maybe that helps.
Hi Karthik and Marcel,
If you want to validate the fields you need to add a validator to them in order to make validation works as expected, you can read more in depth about it in the book of vaadin 5.19 Form, point 5.19.3 Validating Form Input.
For example, extracted from book:
// Postal code that must be 5 digits (10000-99999).
TextField field = new TextField("Postal Code");
field.setColumns(5);
// Create the validator
Validator postalCodeValidator = new RegexpValidator(
"[1-9][0-9]{4}", "Postal code must be a number 10000-99999.");
field.addValidator(postalCodeValidator);
// Set the form to act immediately on user input. This is
// necessary for the validation of the fields to occur immediately
// when the input focus changes and not just on commit.
form.setImmediate(true);
// The Commit button calls form.commit().
Button commit = new Button("Commit", form, "commit");
HTH.
Javi.