From 4c59a7035b247b070e0ab919b2773029e66f2e72 Mon Sep 17 00:00:00 2001 From: Joonas Lehtinen Date: Thu, 3 Jul 2008 15:19:18 +0000 Subject: [PATCH] Fixes ticket #1867 (Error message in Form is empty if required field is empty) svn changeset:5038/svn branch:trunk --- src/com/itmill/toolkit/ui/AbstractField.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index 5d43a7d728..af0108a1d7 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.java @@ -109,7 +109,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Required field. */ private boolean required = false; - + /** * The error message for the exception that is thrown when the field is * required but empty. @@ -616,14 +616,14 @@ public abstract class AbstractField extends AbstractComponent implements Field, return true; } - + /** * Checks the validity of the Validatable by validating the field with all * attached validators. * * The "required" validation is a built-in validation feature. If the field - * is required, but empty, validation will throw an EmptyValueException - * with the error message set with setRequiredError(). + * is required, but empty, validation will throw an EmptyValueException with + * the error message set with setRequiredError(). * * @see com.itmill.toolkit.data.Validatable#validate() */ @@ -729,7 +729,9 @@ public abstract class AbstractField extends AbstractComponent implements Field, try { validate(); } catch (Validator.InvalidValueException e) { - validationError = e; + if (!"".equals(e.getMessage())) { + validationError = e; + } } } @@ -1030,9 +1032,9 @@ public abstract class AbstractField extends AbstractComponent implements Field, this.required = required; requestRepaint(); } - + public void setRequiredError(String requiredMessage) { - this.requiredError = requiredMessage; + requiredError = requiredMessage; requestRepaint(); } -- 2.39.5