summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2011-05-03 11:34:43 +0000
committerHenri Sara <henri.sara@itmill.com>2011-05-03 11:34:43 +0000
commit2042ac08fa22e4f3c827b3fac5ac255f7076cac0 (patch)
treec76857fccc6e38bb1899346096f838d954cea833 /src
parentd75b9a8fe66f22d3f7f401411bd5f9df90d12a52 (diff)
downloadvaadin-framework-2042ac08fa22e4f3c827b3fac5ac255f7076cac0.tar.gz
vaadin-framework-2042ac08fa22e4f3c827b3fac5ac255f7076cac0.zip
#6918 CheckBox/Button in switch mode should support null value
svn changeset:18604/svn branch:6.6
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/Button.java13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java
index 8fa9e2afb9..c64cd386ce 100644
--- a/src/com/vaadin/ui/Button.java
+++ b/src/com/vaadin/ui/Button.java
@@ -188,7 +188,7 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier,
}
// If the button is true for some reason, release it
- if (oldValue.booleanValue()) {
+ if (null == oldValue || oldValue.booleanValue()) {
setValue(Boolean.FALSE);
}
}
@@ -240,13 +240,8 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier,
* @return True iff the button is pressed down or checked.
*/
public boolean booleanValue() {
- boolean state;
- try {
- state = ((Boolean) getValue()).booleanValue();
- } catch (final NullPointerException e) {
- state = false;
- }
- return state;
+ Boolean value = (Boolean) getValue();
+ return (null == value) ? false : value.booleanValue();
}
/**
@@ -475,7 +470,7 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier,
@Override
protected void setInternalValue(Object newValue) {
// Make sure only booleans get through
- if (!(newValue instanceof Boolean)) {
+ if (null != newValue && !(newValue instanceof Boolean)) {
throw new IllegalArgumentException(getClass().getSimpleName()
+ " only accepts Boolean values");
}