/** * {@inheritDoc} * <p> * A Form is empty if all of its fields are empty. * */ @Override public boolean isEmpty() { for (Field<?> f : fields.values()) { if (f instanceof AbstractField) { if (!((AbstractField<?>) f).isEmpty()) { return false; } } } return true; }
/** * For multi-selectable fields, also an empty collection of values is * considered to be an empty field. * * @see LegacyAbstractField#isEmpty(). */ @Override public boolean isEmpty() { if (!multiSelect) { return super.isEmpty(); } else { Object value = getValue(); return super.isEmpty() || (value instanceof Collection && ((Collection<?>) value).isEmpty()); } }
@Override public boolean isEmpty() { return super.isEmpty() || getValue() == DEFAULT_VALUE; } }
@Override public boolean isEmpty() { return super.isEmpty() || getValue().isEmpty(); }
@Override public boolean isEmpty() { return super.isEmpty() || getValue().isEmpty(); }
/** * Returns true if the error indicator be hidden when painting the component * even when there are errors. * * This is a mostly internal method, but can be overridden in subclasses * e.g. if the error indicator should also be shown for empty fields in some * cases. * * @return true to hide the error indicator, false to use the normal logic * to show it when there are errors */ protected boolean shouldHideErrors() { // getErrorMessage() can still return something else than null based on // validation etc. return isRequired() && isEmpty() && getComponentError() == null; }
/** * 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. * <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); } } } }
/** * Checks the validity of the Field. * * A field is invalid if it is set as required (using * {@link #setRequired(boolean)} and is empty, if one or several of the * validators added to the field indicate it is invalid or if the value * cannot be converted provided a converter has been set. * * The "required" validation is a built-in validation feature. If the field * is required and empty this method throws an EmptyValueException with the * error message set using {@link #setRequiredError(String)}. * * @see Validatable#validate() */ @Override public void validate() throws Validator.InvalidValueException { if (isRequired() && isEmpty()) { throw new Validator.EmptyValueException(requiredError); } validate(getFieldValue()); }