]> source.dussan.org Git - vaadin-framework.git/commitdiff
#4107 Multi-selectable AbstractSelect was seen as non-empty when nothing was selected
authorHenri Sara <henri.sara@itmill.com>
Thu, 28 Jan 2010 12:13:51 +0000 (12:13 +0000)
committerHenri Sara <henri.sara@itmill.com>
Thu, 28 Jan 2010 12:13:51 +0000 (12:13 +0000)
svn changeset:11037/svn branch:6.3

src/com/vaadin/ui/AbstractSelect.java

index 4b5ef4a0a8bca40a425da9ac41efedafb42c45f7..088bd5bd0b3ee43b0ef6a708416f27514e0ee654 100644 (file)
@@ -1485,6 +1485,24 @@ public abstract class AbstractSelect extends AbstractField implements
 
     }
 
+    /**
+     * For multi-selectable fields, also an empty collection of values is
+     * considered to be an empty field.
+     * 
+     * @see AbstractField#isEmpty().
+     */
+    @Override
+    protected boolean isEmpty() {
+        if (!multiSelect) {
+            return super.isEmpty();
+        } else {
+            Object value = getValue();
+            return super.isEmpty()
+                    || (value instanceof Collection && ((Collection) value)
+                            .isEmpty());
+        }
+    }
+
     /**
      * Allow of disallow empty selection. If the select is in single-select
      * mode, you can make an item represent the empty selection by calling