throw new NullPointerException(
"Possible causes array must not be null");
}
+
this.causes = causes;
}
+ /**
+ * See if the error message doesn't paint anything visible.
+ *
+ * @return True iff the paint method does not paint anything visible.
+ */
+ public boolean isInvisible() {
+ if (getMessage() != null) {
+ return false;
+ }
+ if (causes != null) {
+ for (int i = 0; i < causes.length; i++) {
+ if (!causes[i].isInvisible()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
public final int getErrorLevel() {
return ErrorMessage.ERROR;
}
if (isEmpty()) {
return false;
}
+ } else {
+ if (isEmpty()) {
+ return true;
+ }
}
if (validators == null) {
// Check validation errors only if automatic validation is enabled.
// As an exception, no validation messages are shown for empty
// required fields, as in those cases user is aware of the problem.
+ // Furthermore, non-required empty fields are obviously correct.
ErrorMessage validationError = null;
- if (isValidationVisible()) {
+ if (isValidationVisible() && !isEmpty()) {
+
try {
validate();
} catch (Validator.InvalidValueException e) {
- String msg = e.getMessage();
- if (msg != null && !"".equals(msg)) {
+ if (!e.isInvisible()) {
validationError = e;
}
}