protected void doEagerValidation() { final boolean wasvalid = eagerValidationStatus; eagerValidationStatus = true; eagerValidationError = null; try { if (isRequired() && getLastKnownTextContent().isEmpty()) { throw new Validator.EmptyValueException(getRequiredError()); } validate(getLastKnownTextContent()); if (!wasvalid) { markAsDirty(); } // Also eagerly pass content to backing bean to make top level // validation eager, but do not listen the value back in value change // event if (getPropertyDataSource() != null) { skipValueChangeEvent = true; Object convertedValue = ConverterUtil.convertToModel( getLastKnownTextContent(), getPropertyDataSource(). getType(), getConverter(), getLocale()); getPropertyDataSource().setValue(convertedValue); skipValueChangeEvent = false; } } catch (Validator.InvalidValueException e) { eagerValidationError = e; eagerValidationStatus = false; markAsDirty(); } }
protected void doEagerValidation() { final boolean wasvalid = eagerValidationStatus; eagerValidationStatus = true; eagerValidationError = null; try { if (isRequired() && getLastKnownTextContent().isEmpty()) { throw new Validator.EmptyValueException(getRequiredError()); } validate(getLastKnownTextContent()); if (!wasvalid) { markAsDirty(); } // Also eagerly pass content to backing bean to make top level // validation eager, but do not listen the value back in value change // event if (getPropertyDataSource() != null) { skipValueChangeEvent = true; Object convertedValue = ConverterUtil.convertToModel( getLastKnownTextContent(), getPropertyDataSource(). getType(), getConverter(), getLocale()); getPropertyDataSource().setValue(convertedValue); skipValueChangeEvent = false; } } catch (Validator.InvalidValueException e) { eagerValidationError = e; eagerValidationStatus = false; markAsDirty(); } }
/** * 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()); }
@Override public void validate() throws Validator.InvalidValueException { if (isEagerValidation() && lastKnownTextChangeValue != null) { // This is most likely not executed, unless someone, for some weird // reason calls this explicitly if (isRequired() && getLastKnownTextContent().isEmpty()) { throw new Validator.EmptyValueException(getRequiredError()); } validate(getLastKnownTextContent()); } else { super.validate(); } }
@Override public ErrorMessage getErrorMessage() { ErrorMessage superError = super.getErrorMessage(); if (!isReadOnly() && isRequired() && isEmpty()) { ErrorMessage error = AbstractErrorMessage.getErrorMessageForException( new com.vaadin.v7.data.Validator.EmptyValueException(getRequiredError())); if (error != null) { return new CompositeErrorMessage(superError, error); } } return superError; }
@Override public ErrorMessage getErrorMessage() { ErrorMessage superError = super.getErrorMessage(); if (!textArea.isReadOnly() && isRequired() && textArea.isEmpty()) { ErrorMessage error = AbstractErrorMessage.getErrorMessageForException( new com.vaadin.v7.data.Validator.EmptyValueException(getRequiredError())); if (error != null) { return new CompositeErrorMessage(superError, error); } } return superError; }
@Override public void validate() throws Validator.InvalidValueException { if (isEagerValidation() && lastKnownTextChangeValue != null) { // This is most likely not executed, unless someone, for some weird // reason calls this explicitly if (isRequired() && getLastKnownTextContent().isEmpty()) { throw new Validator.EmptyValueException(getRequiredError()); } validate(getLastKnownTextContent()); } else { super.validate(); } }
@Override public ErrorMessage getErrorMessage() { ErrorMessage superError = super.getErrorMessage(); if (!textField.isReadOnly() && textField.isRequiredIndicatorVisible() && textField.isEmpty()) { ErrorMessage error = AbstractErrorMessage.getErrorMessageForException( new com.vaadin.v7.data.Validator.EmptyValueException(getRequiredError())); if (error != null) { return new CompositeErrorMessage(superError, error); } } return superError; }