I have a BeanFieldGroup
with several validators, and a Save
button that commits the form.
But if I have eg a @NotBlank
validation constraint on my entity, and the input field is empty by default, I already get an error icon beneath initially when showing the form.
public class UserView {
private BeanFieldGroup<User> editor;
private Button saveBtn;
public UserView() {
saveBtn = new Button("Save", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
editor.commit();
} catch (CommitException e) {
e.printStackTrace();
}
}
});
}
}
For checking for errors there is isValid
https://vaadin.com/api/7.2.0/com/vaadin/data/fieldgroup/FieldGroup.html#isValid%28%29 (see the implementation: it iterates over the fields and calls validate more or less). if you need the errors you can pick them up there. after the commit you might also use the javax.validation machinery again on the object itself.
for hiding the errors you could play around with AbstractField
s' setValidationVisible
method.