1 package org.apache.myfaces.tobago.taglib.extension12;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import org.apache.commons.lang.StringUtils;
21 import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
22 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
23 import org.apache.myfaces.tobago.apt.annotation.Tag;
24 import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
25 import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
26 import org.apache.myfaces.tobago.component.Attributes;
27 import org.apache.myfaces.tobago.component.Facets;
28 import org.apache.myfaces.tobago.component.UICommandBase;
29 import org.apache.myfaces.tobago.internal.taglib.MenuItemTag;
30 import org.apache.myfaces.tobago.internal.taglib.SelectOneRadioTag;
31
32 import javax.faces.component.UIComponent;
33 import javax.faces.webapp.FacetTag;
34 import javax.servlet.jsp.JspException;
35 import javax.servlet.jsp.tagext.BodyTagSupport;
36
37
38
39
40
41
42
43
44
45
46 @Tag(name = "menuRadio", tagExtraInfoClassName = "org.apache.myfaces.tobago.taglib.component.CommandTagExtraInfo")
47 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.internal.taglib.MenuRadioTag")
48 public class MenuRadioExtensionTag extends BodyTagSupport {
49
50 private javax.el.ValueExpression rendered;
51 private javax.el.ValueExpression value;
52
53 private MenuItemTag menuCommandTag;
54 private SelectOneRadioTag selectOneRadio;
55 private FacetTag facetTag;
56 private javax.el.MethodExpression action;
57 private javax.el.MethodExpression actionListener;
58 private javax.el.ValueExpression onclick;
59 private javax.el.ValueExpression link;
60 private javax.el.ValueExpression disabled;
61 private javax.el.ValueExpression binding;
62 private javax.el.ValueExpression label;
63 private javax.el.ValueExpression immediate;
64 private javax.el.ValueExpression transition;
65 private javax.el.ValueExpression converter;
66 private javax.el.ValueExpression renderedPartially;
67
68 @Override
69 public int doStartTag() throws JspException {
70
71 menuCommandTag = new MenuItemTag();
72 menuCommandTag.setPageContext(pageContext);
73 menuCommandTag.setParent(getParent());
74
75 if (rendered != null) {
76 menuCommandTag.setRendered(rendered);
77 }
78 if (action != null) {
79 menuCommandTag.setAction(action);
80 }
81 if (actionListener != null) {
82 menuCommandTag.setActionListener(actionListener);
83 }
84 if (onclick != null) {
85 menuCommandTag.setOnclick(onclick);
86 }
87 if (link != null) {
88 menuCommandTag.setLink(link);
89 }
90 if (disabled != null) {
91 menuCommandTag.setDisabled(disabled);
92 }
93 if (binding != null) {
94 menuCommandTag.setBinding(binding);
95 }
96 if (label != null) {
97 menuCommandTag.setLabel(label);
98 }
99 if (immediate != null) {
100 menuCommandTag.setImmediate(immediate);
101 }
102 if (transition != null) {
103 menuCommandTag.setTransition(transition);
104 }
105 if (renderedPartially != null) {
106 menuCommandTag.setRenderedPartially(renderedPartially);
107 }
108 menuCommandTag.doStartTag();
109
110 facetTag = new FacetTag();
111 facetTag.setPageContext(pageContext);
112 facetTag.setParent(menuCommandTag);
113 facetTag.setName(Facets.ITEMS);
114
115 facetTag.doStartTag();
116 selectOneRadio = new SelectOneRadioTag();
117 selectOneRadio.setPageContext(pageContext);
118 selectOneRadio.setParent(facetTag);
119 if (converter != null) {
120 selectOneRadio.setConverter(converter);
121 }
122 if (value != null) {
123 selectOneRadio.setValue(value);
124 }
125 selectOneRadio.doStartTag();
126
127 return super.doStartTag();
128 }
129
130 @Override
131 public int doEndTag() throws JspException {
132
133 if (renderedPartially == null) {
134
135 UIComponent selectOneComponent = selectOneRadio.getComponentInstance();
136 UICommandBase command = (UICommandBase) menuCommandTag.getComponentInstance();
137 javax.el.ValueExpression expression = selectOneComponent.getValueExpression(Attributes.RENDERED_PARTIALLY);
138 if (expression != null) {
139 command.setValueExpression(Attributes.RENDERED_PARTIALLY, expression);
140 } else {
141 Object renderedPartially = selectOneComponent.getAttributes().get(Attributes.RENDERED_PARTIALLY);
142 command.setRenderedPartially(StringUtils.split((String) renderedPartially, ", "));
143 }
144 }
145
146 selectOneRadio.doEndTag();
147 facetTag.doEndTag();
148 menuCommandTag.doEndTag();
149
150 return super.doEndTag();
151 }
152
153
154
155
156
157
158
159
160
161
162 @TagAttribute
163 @UIComponentTagAttribute(type = {}, expression = DynamicExpression.METHOD_BINDING,
164 methodReturnType = "java.lang.Object")
165 public void setAction(javax.el.MethodExpression action) {
166 this.action = action;
167 }
168
169
170
171
172
173
174
175 @TagAttribute
176 @UIComponentTagAttribute(type = {}, expression = DynamicExpression.METHOD_BINDING_REQUIRED,
177 methodSignature = "javax.faces.event.ActionEvent")
178 public void setActionListener(javax.el.MethodExpression actionListener) {
179 this.actionListener = actionListener;
180 }
181
182
183
184
185
186
187 @TagAttribute
188 @UIComponentTagAttribute()
189 public void setOnclick(javax.el.ValueExpression onclick) {
190 this.onclick = onclick;
191 }
192
193
194
195
196
197
198 @TagAttribute
199 @UIComponentTagAttribute()
200 public void setLink(javax.el.ValueExpression link) {
201 this.link = link;
202 }
203
204
205
206
207
208 @TagAttribute
209 @UIComponentTagAttribute(type = "javax.faces.component.UIComponent")
210 public void setBinding(javax.el.ValueExpression binding) throws JspException {
211 this.binding = binding;
212 }
213
214
215
216
217
218 @TagAttribute
219 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.TRUE")
220 public void setRendered(javax.el.ValueExpression rendered) {
221 this.rendered = rendered;
222 }
223
224
225
226
227 @TagAttribute()
228 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.FALSE")
229 public void setDisabled(javax.el.ValueExpression disabled) {
230 this.disabled = disabled;
231 }
232
233
234
235
236 @TagAttribute
237 @UIComponentTagAttribute(type = "java.lang.Object")
238 public void setValue(javax.el.ValueExpression value) {
239 this.value = value;
240 }
241
242
243
244
245
246 @TagAttribute
247 @UIComponentTagAttribute()
248 public void setLabel(javax.el.ValueExpression label) {
249 this.label = label;
250 }
251
252
253
254
255
256
257
258 @TagAttribute
259 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.FALSE")
260 public void setImmediate(javax.el.ValueExpression immediate) {
261 this.immediate = immediate;
262 }
263
264
265
266
267
268
269
270 @TagAttribute
271 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.TRUE")
272 public void setTransition(javax.el.ValueExpression transition) {
273 this.transition = transition;
274 }
275
276
277
278
279
280
281
282
283
284
285 @TagAttribute
286 @UIComponentTagAttribute(type = "javax.faces.convert.Converter",
287 expression = DynamicExpression.VALUE_BINDING)
288 public void setConverter(javax.el.ValueExpression converter) {
289 this.converter = converter;
290 }
291
292
293
294
295 @TagAttribute
296 @UIComponentTagAttribute(type = "java.lang.String[]")
297 public void setRenderedPartially(javax.el.ValueExpression renderedPartially) {
298 this.renderedPartially = renderedPartially;
299 }
300
301 public void release() {
302 super.release();
303 rendered = null;
304 value = null;
305 action = null;
306 actionListener = null;
307 onclick = null;
308 link = null;
309 disabled = null;
310 binding = null;
311 label = null;
312 immediate = null;
313 transition = null;
314 converter = null;
315 renderedPartially = null;
316 menuCommandTag = null;
317 facetTag = null;
318 selectOneRadio = null;
319 }
320
321 }