Source code: com/webobjects/woextensions/WORadioButtonMatrix.java
1 /*
2 * WORadioButtonMatrix.java
3 * © Copyright 2001 Apple Computer, Inc. All rights reserved.
4 * This a modified version.
5 * Original license: http://www.opensource.apple.com/apsl/
6 */
7
8 package com.webobjects.woextensions;
9
10
11 import com.webobjects.appserver.*;
12 import com.webobjects.foundation.*;
13
14 public class WORadioButtonMatrix extends WOComponent {
15 public Object currentItem;
16 public int index;
17 public String wrapperElementID;
18 protected Object _selection = null;
19
20 public WORadioButtonMatrix(WOContext aContext) {
21 super(aContext);
22 }
23
24 public void setCurrentItem(Object aValue) {
25 currentItem = aValue;
26 setValueForBinding(aValue, "item");
27 }
28
29 public Object selection() {
30 if (_selection==null) {
31 // ** only pull this one time
32 _selection = valueForBinding("selection");
33 }
34 return _selection;
35 }
36
37 public void setSelection(String anIndex) {
38 if (anIndex != null) {
39 int idx = Integer.parseInt(anIndex);
40 // ** push the selection to the parent
41 NSArray anItemList = (NSArray)_WOJExtensionsUtil.valueForBindingOrNull("list",this);
42 Object aSelectedObject = anItemList.objectAtIndex(idx);
43 setValueForBinding(aSelectedObject, "selection");
44 }
45 // ** and force it to be pulled if there's a next time.
46 _selection = null;
47 }
48
49 public String isCurrentItemSelected() {
50
51 if (selection() != null && selection().equals(currentItem)) {
52 return "checked";
53 }
54
55 return null;
56 }
57
58 protected void _invalidateCaches() {
59 _selection = null;
60 currentItem = null;
61 }
62
63 public boolean isStateless() {
64 return true;
65 }
66
67 public void reset() {
68 _invalidateCaches();
69 }
70 }