01: /*
02: * Created on Jul 28, 2005
03: */
04: package uk.org.ponder.rsf.components;
05:
06: import uk.org.ponder.rsf.uitype.BooleanUIType;
07:
08: /**
09: * Component holding a single boolean value, which will peer with a component
10: * such as a checkbox or radio button.
11: *
12: * @author Antranig Basman (antranig@caret.cam.ac.uk)
13: *
14: */
15: public class UIBoundBoolean extends UIBound {
16:
17: public boolean getValue() {
18: return ((Boolean) value).booleanValue();
19: }
20:
21: public void setValue(boolean value) {
22: this .value = value ? Boolean.TRUE : Boolean.FALSE;
23: }
24:
25: public UIBoundBoolean() {
26: value = BooleanUIType.instance.getPlaceholder();
27: fossilize = true;
28: willinput = true;
29: }
30:
31: public static UIBoundBoolean make(UIContainer parent, String ID,
32: String binding, Boolean initvalue) {
33: UIBoundBoolean togo = new UIBoundBoolean();
34: togo.valuebinding = ELReference.make(binding);
35: togo.fossilize = binding != null;
36: if (initvalue != null) {
37: togo.setValue(initvalue.booleanValue());
38: }
39: togo.ID = ID;
40: parent.addComponent(togo);
41: return togo;
42: }
43:
44: public static UIBoundBoolean make(UIBranchContainer parent,
45: String ID, String binding, boolean initvalue) {
46: return make(parent, ID, binding, initvalue ? Boolean.TRUE
47: : Boolean.FALSE);
48: }
49:
50: public static UIBoundBoolean make(UIContainer parent, String ID,
51: String binding) {
52: return make(parent, ID, binding, null);
53: }
54:
55: public static UIBoundBoolean make(UIContainer parent, String ID,
56: Boolean initvalue) {
57: return make(parent, ID, null, initvalue);
58: }
59:
60: public static UIBoundBoolean make(UIContainer parent, String ID,
61: boolean initvalue) {
62: return make(parent, ID, null, initvalue ? Boolean.TRUE
63: : Boolean.FALSE);
64: }
65:
66: /** Suitable for a non-bound control such as in a GET form */
67: public static UIBoundBoolean make(UIContainer parent, String ID) {
68: return make(parent, ID, null, (Boolean) null);
69: }
70:
71: }
|