this.value = getDatatype().convertFromString(this.enteredValue, getForm().getLocale());
if (this.value != null) { // Conversion successfull
this.needsParse = false;
this.needsValidate = true;
} else { // Conversion failed
this.validationError = new ValidationError(new I18nMessage(
"datatype.conversion-failed",
new String[] {"datatype." + getDatatype().getDescriptiveName()},
new boolean[] { true },
Constants.I18N_CATALOGUE
));
// No need for further validation (and need to keep the above error)
this.needsValidate = false;
}
} else {
this.needsParse = false;
this.needsValidate = true;
}
}
// if getValue() is called on this field while we're validating, then it's because a validation
// rule called getValue(), so then we just return the parsed (but not validated) value to avoid an endless loop
if (isValidating) {
return value;
}
// Validate the value
if (this.needsValidate) {
isValidating = true;
try {
if (super.validate(null)) {
// New-style validators were successful. Check the old-style ones.
if (this.value != null) {
this.validationError = getDatatype().validate(value, new ExpressionContextImpl(this));
} else { // No value : is it required ?
if (getFieldDefinition().isRequired()) {
this.validationError = new ValidationError(new I18nMessage("general.field-required", Constants.I18N_CATALOGUE));
}
}
}
this.needsValidate = false;
} finally {