diff options
Diffstat (limited to 'src/com/vaadin/ui')
-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); } } |