Example usage for com.vaadin.v7.ui AbstractField getErrorMessage

List of usage examples for com.vaadin.v7.ui AbstractField getErrorMessage

Introduction

In this page you can find the example usage for com.vaadin.v7.ui AbstractField getErrorMessage.

Prototype

@Override
public ErrorMessage getErrorMessage() 

Source Link

Document

Error messages shown by the fields are composites of the error message thrown by the superclasses (that is the component error message), validation errors and buffered source errors.

Usage

From source file:org.vaadin.viritin.v7.MBeanFieldGroup.java

License:Apache License

/**
 * This method hides validation errors on a required fields until the field
 * has been changed for the first time. Does pretty much the same as old
 * Vaadin Form did with its validationVisibleOnCommit, but eagerly per
 * field./*from  w w  w .  j  ava 2  s.  co m*/
 * <p>
 * Fields that hide validation errors this way are available in
 * getFieldsWithIntiallyDisabledValidation() so they can be emphasized in
 * UI.
 */
public void hideInitialEmpyFieldValidationErrors() {
    fieldsWithInitiallyDisabledValidation.clear();
    for (Field<?> f : getFields()) {
        if (f instanceof AbstractField) {
            final AbstractField<?> abstractField = (AbstractField<?>) f;
            if (abstractField.getErrorMessage() != null && abstractField.isRequired() && abstractField.isEmpty()
                    && abstractField.isValidationVisible()) {
                final String propertyId = getPropertyId(abstractField).toString();
                abstractField.setValidationVisible(false);
                fieldsWithInitiallyDisabledValidation.add(propertyId);
            }
        }
    }
}