membersound membersound - 1 year ago 79
Java Question

How to only show errors on commit of BeanFieldGroup?

I have a

with several validators, and a
button that commits the form.
But if I have eg a
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.

  • How can I prevent this?

  • How can I then show the icons again if there are any validation errors on commit?

  • Check if the BeanFieldGroup has any validation errors?

public class UserView {
private BeanFieldGroup<User> editor;
private Button saveBtn;

public UserView() {
saveBtn = new Button("Save", new ClickListener() {
public void buttonClick(ClickEvent event) {
try {
} catch (CommitException e) {

Answer Source

For checking for errors there is isValid (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 AbstractFields' setValidationVisible method.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download