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