diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-10-30 08:21:39 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-10-30 08:21:39 +0000 |
commit | 3b48b5012a287a8e33ed4b89f1205268c8690e32 (patch) | |
tree | 352725ca1a1189ef1e992264b4e9652f28f196bc /src/com/itmill/toolkit/ui/Button.java | |
parent | 8709db691628f3a3e6884de8c1c6574b8ad2c817 (diff) | |
download | vaadin-framework-3b48b5012a287a8e33ed4b89f1205268c8690e32.tar.gz vaadin-framework-3b48b5012a287a8e33ed4b89f1205268c8690e32.zip |
Cleaned Button & CheckBox code, now ensures button has initial value false.
svn changeset:5767/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/Button.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/Button.java | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java index 9e51b81576..0812f261ff 100644 --- a/src/com/itmill/toolkit/ui/Button.java +++ b/src/com/itmill/toolkit/ui/Button.java @@ -32,6 +32,7 @@ public class Button extends AbstractField { * */ public Button() { + setValue(new Boolean(false)); setSwitchMode(false); } @@ -45,8 +46,8 @@ public class Button extends AbstractField { * the Button caption. */ public Button(String caption) { + this(); setCaption(caption); - setSwitchMode(false); } /** @@ -134,14 +135,7 @@ public class Button extends AbstractField { if (isSwitchMode()) { target.addAttribute("type", "switch"); } - boolean state; - try { - state = ((Boolean) getValue()).booleanValue(); - } catch (final NullPointerException e) { - state = false; - } - target.addVariable(this, "state", state); - + target.addVariable(this, "state", booleanValue()); } /** @@ -203,7 +197,9 @@ public class Button extends AbstractField { this.switchMode = switchMode; if (!switchMode) { setImmediate(true); - setValue(new Boolean(false)); + if (booleanValue()) { + setValue(new Boolean(false)); + } } } @@ -213,7 +209,13 @@ public class Button extends AbstractField { * @return True iff the button is pressed down or checked. */ public boolean booleanValue() { - return ((Boolean) getValue()).booleanValue(); + boolean state; + try { + state = ((Boolean) getValue()).booleanValue(); + } catch (final NullPointerException e) { + state = false; + } + return state; } /** |