diff options
author | Henri Sara <henri.sara@itmill.com> | 2011-09-05 13:16:06 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2011-09-05 13:16:06 +0000 |
commit | 175c380a0471bf916e683e43f4a9f561c730e7b1 (patch) | |
tree | a3901629d4f5b307f5ae6d7e3cfcced41e38bc24 /src | |
parent | 97b7f1244d75e42c14ac034de6712a4d42de3c22 (diff) | |
download | vaadin-framework-175c380a0471bf916e683e43f4a9f561c730e7b1.tar.gz vaadin-framework-175c380a0471bf916e683e43f4a9f561c730e7b1.zip |
#6770 error indicator should not be hidden when a DateField is "empty" because it has an invalid date string
svn changeset:20851/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/ui/AbstractField.java | 19 | ||||
-rw-r--r-- | src/com/vaadin/ui/DateField.java | 7 | ||||
-rw-r--r-- | src/com/vaadin/ui/Select.java | 3 |
3 files changed, 24 insertions, 5 deletions
diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index 097de6f705..b7666f6341 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -163,12 +163,27 @@ public abstract class AbstractField extends AbstractComponent implements Field, } // Hide the error indicator if needed - if (isRequired() && isEmpty() && getComponentError() == null - && getErrorMessage() != null) { + if (shouldHideErrors()) { target.addAttribute("hideErrors", true); } } + /** + * 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() { + return isRequired() && isEmpty() && getComponentError() == null + && getErrorMessage() != null; + } + /* * Gets the field type Don't add a JavaDoc comment here, we use the default * documentation from the implemented interface. diff --git a/src/com/vaadin/ui/DateField.java b/src/com/vaadin/ui/DateField.java index 1ecf616832..b6e3d1e8cb 100644 --- a/src/com/vaadin/ui/DateField.java +++ b/src/com/vaadin/ui/DateField.java @@ -276,6 +276,11 @@ public class DateField extends AbstractField implements } } + @Override + protected boolean shouldHideErrors() { + return super.shouldHideErrors() && uiHasValidDateString; + } + /* * Invoked when a variable of the component changes. Don't add a JavaDoc * comment here, we use the default documentation from implemented @@ -293,7 +298,7 @@ public class DateField extends AbstractField implements || variables.containsKey("min") || variables.containsKey("sec") || variables.containsKey("msec") || variables - .containsKey("dateString"))) { + .containsKey("dateString"))) { // Old and new dates final Date oldDate = (Date) getValue(); diff --git a/src/com/vaadin/ui/Select.java b/src/com/vaadin/ui/Select.java index d6530991e6..7b6fc07e5b 100644 --- a/src/com/vaadin/ui/Select.java +++ b/src/com/vaadin/ui/Select.java @@ -273,8 +273,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, optionRequest = true; // Hide the error indicator if needed - if (isRequired() && isEmpty() && getComponentError() == null - && getErrorMessage() != null) { + if (shouldHideErrors()) { target.addAttribute("hideErrors", true); } } |