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.
I am having issues with getting Form validations done. I am creating my own components like text fields etc using new () operator and am adding it to the form.
form = new Form();form.setImmediate(true);form.setValidationVisible(true);
firstName = new TextField("First name");firstName.setImmediate(true);firstName.setRequired(true);firstName.setRequiredError("First name is mandatory");form.getLayout().addComponent(firstName);
I also create the button as
Button btn = new Button("Save",form,"commit");
I am NOT using the form.setItemDataContainer() method to bind a pojo. All I want to get done is that the required fields get validated on clicking of the save button.
Somehow validation does not seem to work.
Is it mandatory that i need a form bound to a container for validations to work ?
Any tips on getting this right ?
Looks like replacing
does the trick.
Edit:Also I manually call form.validate() on click of the button