Example usage for com.vaadin.v7.data.fieldgroup FieldGroup commit

List of usage examples for com.vaadin.v7.data.fieldgroup FieldGroup commit

Introduction

In this page you can find the example usage for com.vaadin.v7.data.fieldgroup FieldGroup commit.

Prototype

public void commit() throws CommitException 

Source Link

Document

Commits all changes done to the bound fields.

Usage

From source file:de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.java

License:Open Source License

@Override
public void commit() throws InvalidValueException, SourceException, CommitRuntimeException {

    if (fieldGroups != null) {
        if (fieldGroups.length > 1) {
            // validate all fields first, so commit will likely work for all fieldGroups
            // this is basically only needed when we have multiple field groups
            // FIXME this leads to problem #537 for AbstractEditForm with hideValidationUntilNextCommit 
            // can hopefully be fixed easier with Vaadin 8 architecture change
            getFieldsStream().forEach(field -> {
                if (!field.isInvalidCommitted()) {
                    field.validate();// www.j  a va2  s .  com
                }
            });
        }

        try {
            for (FieldGroup fieldGroup : fieldGroups) {
                fieldGroup.commit();
            }
        } catch (CommitException e) {
            if (e.getCause() instanceof InvalidValueException)
                throw (InvalidValueException) e.getCause();
            else if (e.getCause() instanceof SourceException)
                throw (SourceException) e.getCause();
            else
                throw new CommitRuntimeException(e);
        }
    } else if (wrappedComponent instanceof Buffered) {
        ((Buffered) wrappedComponent).commit();
    } else {
        // NOOP
    }

    onCommit();
    commited = true;

    onDone();
}