diff options
author | Artur Signell <artur.signell@itmill.com> | 2008-11-24 14:50:32 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2008-11-24 14:50:32 +0000 |
commit | 5cf770c597a22c97517fb25486de04d50d296e38 (patch) | |
tree | 858ccbc1293a56fc4b726b8361376f1f12f94a2c /src/com/itmill/toolkit/ui/Button.java | |
parent | 8665aac686c47c11c7e056245098adc6b6fa8e01 (diff) | |
download | vaadin-framework-5cf770c597a22c97517fb25486de04d50d296e38.tar.gz vaadin-framework-5cf770c597a22c97517fb25486de04d50d296e38.zip |
Test case and fix for #2151 - Button should not accept invalid values.
svn changeset:5966/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/Button.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/Button.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java index 0812f261ff..2bd0aac48d 100644 --- a/src/com/itmill/toolkit/ui/Button.java +++ b/src/com/itmill/toolkit/ui/Button.java @@ -27,8 +27,8 @@ public class Button extends AbstractField { boolean switchMode = false; /** - * Creates a new push button. The value of the push button is allways false - * and they are immediate by default. + * Creates a new push button. The value of the push button is false and it + * is immediate by default. * */ public Button() { @@ -39,8 +39,7 @@ public class Button extends AbstractField { /** * Creates a new push button. * - * The value of the push button is allways false and they are immediate by - * default. + * The value of the push button is false and it is immediate by default. * * @param caption * the Button caption. @@ -336,4 +335,14 @@ public class Button extends AbstractField { fireEvent(new Button.ClickEvent(this)); } + @Override + protected void setInternalValue(Object newValue) { + // Make sure only booleans get through + if (!(newValue instanceof Boolean)) { + throw new IllegalArgumentException(getClass().getSimpleName() + + " only accepts Boolean values"); + } + super.setInternalValue(newValue); + } + } |