1
2
3
4 package org.rcfaces.core.item;
5
6 import java.util.HashMap;
7 import java.util.Map;
8
9 import javax.faces.component.UISelectItem;
10 import javax.faces.model.SelectItem;
11 import javax.faces.model.SelectItemGroup;
12
13
14
15
16
17
18 public class BasicSelectItemGroup extends SelectItemGroup implements
19 ISelectItemGroup, IAccessKeyItem, IAcceleratorKeyItem,
20 IGroupSelectItem, IInputTypeItem, IVisibleItem, IServerDataItem,
21 IClientDataItem, IStyleClassItem {
22 private static final String REVISION = "$Revision: 1.3 $";
23
24 private static final long serialVersionUID = 6953469102413843158L;
25
26 private static final String[] STRING_EMPTY_ARRAY = new String[0];
27
28 private Map serverDatas;
29
30 private Map clientDatas;
31
32 private String accessKey;
33
34 private String acceleratorKey;
35
36 private String groupName;
37
38 private boolean checked;
39
40 private boolean visible = true;
41
42 private int inputType;
43
44 private String styleClass;
45
46 public BasicSelectItemGroup() {
47 }
48
49 public BasicSelectItemGroup(String label) {
50 super(label);
51 }
52
53 public BasicSelectItemGroup(Object value, String label, String description,
54 boolean disabled, SelectItem selectItems[]) {
55 super(label, description, disabled, selectItems);
56 }
57
58 public BasicSelectItemGroup(ISelectItem selectItem) {
59 super(selectItem.getLabel());
60
61 String description = selectItem.getDescription();
62 if (description != null) {
63 setDescription(description);
64 }
65
66 if (selectItem.isDisabled()) {
67 setDisabled(true);
68 }
69
70 setValue(selectItem.getValue());
71 }
72
73 public BasicSelectItemGroup(ISelectItemGroup selectItemGroup) {
74 super(selectItemGroup.getLabel());
75
76 String description = selectItemGroup.getDescription();
77 if (description != null) {
78 setDescription(description);
79 }
80
81 if (selectItemGroup.isDisabled()) {
82 setDisabled(true);
83 }
84
85 SelectItem children[] = selectItemGroup.getSelectItems();
86 if (children != null) {
87 setSelectItems(children);
88 }
89
90 setValue(selectItemGroup.getValue());
91 }
92
93
94
95
96
97
98 public String getAccessKey() {
99 return accessKey;
100 }
101
102 public String getGroupName() {
103 return groupName;
104 }
105
106 public static Object getValue(UISelectItem component) {
107 Object value = component.getItemValue();
108 if (value != null) {
109 return value;
110 }
111
112
113
114 return component.getId();
115 }
116
117
118
119
120
121
122 public boolean isChecked() {
123 return checked;
124 }
125
126 public int getInputType() {
127 return inputType;
128 }
129
130 public boolean isVisible() {
131 return visible;
132 }
133
134 public void setAccessKey(String accessKey) {
135 this.accessKey = accessKey;
136 }
137
138 public void setChecked(boolean checked) {
139 this.checked = checked;
140 }
141
142 public void setGroupName(String groupName) {
143 this.groupName = groupName;
144 }
145
146 public void setInputType(int inputType) {
147 this.inputType = inputType;
148 }
149
150 public void setVisible(boolean visible) {
151 this.visible = visible;
152 }
153
154 public boolean isServerDataEmpty() {
155 if (serverDatas == null) {
156 return true;
157 }
158
159 return serverDatas.isEmpty();
160 }
161
162 public Map getServerDataMap() {
163 if (serverDatas == null) {
164 serverDatas = new HashMap();
165 }
166
167 return serverDatas;
168 }
169
170 public boolean isClientDataEmpty() {
171 if (clientDatas == null) {
172 return true;
173 }
174
175 return clientDatas.isEmpty();
176 }
177
178 public Map getClientDataMap() {
179 if (clientDatas == null) {
180 clientDatas = new HashMap();
181 }
182
183 return clientDatas;
184 }
185
186 public String getStyleClass() {
187 return styleClass;
188 }
189
190 public String getAcceleratorKey() {
191 return acceleratorKey;
192 }
193 }