summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java')
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java124
1 files changed, 62 insertions, 62 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java
index 5d22d36..8e706c1 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCheckBox.java
@@ -7,75 +7,75 @@ import net.wotonomy.foundation.NSMutableArray;
public class WOCheckBox extends WOInput {
- protected boolean checked = false;
+ protected boolean checked = false;
- public WOCheckBox() {
- super();
- }
+ public WOCheckBox() {
+ super();
+ }
- public WOCheckBox(String aName, NSDictionary assocs, WOElement template) {
- super(aName, assocs, template);
- }
+ public WOCheckBox(String aName, NSDictionary assocs, WOElement template) {
+ super(aName, assocs, template);
+ }
- protected String inputType() {
- return "CHECKBOX";
- }
+ protected String inputType() {
+ return "CHECKBOX";
+ }
- protected Object value(WOContext c) {
- Object val = null;
- boolean checked = false;
- if (associations.objectForKey("value") != null) {
- val = valueForProperty("value", c.component());
- Object sel = valueForProperty("selection", c.component());
- if (sel != null && val != null && sel.equals(val))
- checked = true;
- }
- if (val == null) {
- val = c.elementID();
- }
- return val;
- }
+ protected Object value(WOContext c) {
+ Object val = null;
+ boolean checked = false;
+ if (associations.objectForKey("value") != null) {
+ val = valueForProperty("value", c.component());
+ Object sel = valueForProperty("selection", c.component());
+ if (sel != null && val != null && sel.equals(val))
+ checked = true;
+ }
+ if (val == null) {
+ val = c.elementID();
+ }
+ return val;
+ }
- protected void appendExtras(WOResponse r, WOContext c) {
- checked |= booleanForProperty("checked", c.component());
- if (checked)
- r.appendContentString(" CHECKED");
- }
+ protected void appendExtras(WOResponse r, WOContext c) {
+ checked |= booleanForProperty("checked", c.component());
+ if (checked)
+ r.appendContentString(" CHECKED");
+ }
- protected NSMutableArray additionalAttributes() {
- NSMutableArray a = super.additionalAttributes();
- a.addObject("checked");
- a.addObject("selection");
- return a;
- }
+ protected NSMutableArray additionalAttributes() {
+ NSMutableArray a = super.additionalAttributes();
+ a.addObject("checked");
+ a.addObject("selection");
+ return a;
+ }
- public void appendToResponse(WOResponse r, WOContext c) {
- checked = false;
- super.appendToResponse(r, c);
- }
+ public void appendToResponse(WOResponse r, WOContext c) {
+ checked = false;
+ super.appendToResponse(r, c);
+ }
- public void takeValuesFromRequest(WORequest r, WOContext c) {
- if (disabled(c))
- return;
- NSArray values = r.formValuesForKey(inputName(c));
- Object val = valueForProperty("value", c.component());
- if (val == null)
- val = c.elementID();
- java.util.Enumeration enumerator = values.objectEnumerator();
- checked = false;
- while (enumerator.hasMoreElements()) {
- Object nextval = enumerator.nextElement();
- if (nextval.equals(val))
- checked = true;
- }
- if (associations.objectForKey("value") != null && associations.objectForKey("selection") != null) {
- if (checked)
- setValueForProperty("selection", val, c.component());
- else if (valueForProperty("selection", c.component()) != null)
- setValueForProperty("selection", null, c.component());
- }
- if (associations.objectForKey("checked") != null)
- setValueForProperty("checked", checked ? Boolean.TRUE : Boolean.FALSE, c.component());
- }
+ public void takeValuesFromRequest(WORequest r, WOContext c) {
+ if (disabled(c))
+ return;
+ NSArray values = r.formValuesForKey(inputName(c));
+ Object val = valueForProperty("value", c.component());
+ if (val == null)
+ val = c.elementID();
+ java.util.Enumeration enumerator = values.objectEnumerator();
+ checked = false;
+ while (enumerator.hasMoreElements()) {
+ Object nextval = enumerator.nextElement();
+ if (nextval.equals(val))
+ checked = true;
+ }
+ if (associations.objectForKey("value") != null && associations.objectForKey("selection") != null) {
+ if (checked)
+ setValueForProperty("selection", val, c.component());
+ else if (valueForProperty("selection", c.component()) != null)
+ setValueForProperty("selection", null, c.component());
+ }
+ if (associations.objectForKey("checked") != null)
+ setValueForProperty("checked", checked ? Boolean.TRUE : Boolean.FALSE, c.component());
+ }
} \ No newline at end of file