]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #1900
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Fri, 24 Oct 2008 14:19:43 +0000 (14:19 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Fri, 24 Oct 2008 14:19:43 +0000 (14:19 +0000)
svn changeset:5720/svn branch:trunk

src/com/itmill/toolkit/data/Validator.java
src/com/itmill/toolkit/terminal/gwt/client/ICaption.java
src/com/itmill/toolkit/ui/AbstractField.java

index 3bbd75e3dccf3bfe66ea87e66e7f70dc1a01072e..0e09e3de6bae15d073477fac715da20cc642ec9f 100644 (file)
@@ -105,7 +105,8 @@ public interface Validator {
          * @return True iff the paint method does not paint anything visible.
          */
         public boolean isInvisible() {
-            if (getMessage() != null) {
+            String msg = getMessage();
+            if (msg != null && msg.length() > 0) {
                 return false;
             }
             if (causes != null) {
index 513a585841ac69898dc9db26404068ac78d34975..fb626b34aa1b1de6e3c76a7dfa58c546082d202a 100644 (file)
@@ -137,7 +137,8 @@ public class ICaption extends HTML {
             }
         }
 
-        if (uidl.hasAttribute("error")) {
+        if (uidl.hasAttribute("error")
+                && !uidl.getBooleanAttribute("hideErrors")) {
             isEmpty = false;
             if (errorIndicatorElement == null) {
                 errorIndicatorElement = DOM.createDiv();
index 66eef1d6dfbba06b858c708c2b1fa03517daaf83..2fa622c7d86e798ce15370354b2676d9e56bb56f 100644 (file)
@@ -143,6 +143,12 @@ public abstract class AbstractField extends AbstractComponent implements Field,
         if (isRequired()) {
             target.addAttribute("required", true);
         }
+
+        // Hide the error indicator if needed
+        if (isRequired() && isEmpty() && getComponentError() == null
+                && getErrorMessage() != null) {
+            target.addAttribute("hideErrors", true);
+        }
     }
 
     /*
@@ -757,7 +763,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
         // 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() && !isEmpty()) {
+        if (isValidationVisible() && !(isEmpty() && !isRequired())) {
 
             try {
                 validate();