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

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

Introduction

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

Prototype

@Override
    public boolean isRequired() 

Source Link

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  av  a2  s  . c  om
 * <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);
            }
        }
    }
}