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.SelectBooleanCheckboxTag;
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 = "menuCheckbox", tagExtraInfoClassName = "org.apache.myfaces.tobago.taglib.component.CommandTagExtraInfo")
47 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.MenuCheckboxTag")
48 public class MenuCheckboxExtensionTag extends BodyTagSupport {
49 private javax.el.ValueExpression rendered;
50 private javax.el.ValueExpression value;
51
52 private MenuItemTag menuCommandTag;
53 private SelectBooleanCheckboxTag selectBooleanCheckbox;
54 private FacetTag facetTag;
55 private javax.el.MethodExpression action;
56 private javax.el.MethodExpression actionListener;
57 private javax.el.ValueExpression onclick;
58 private javax.el.ValueExpression link;
59 private javax.el.ValueExpression disabled;
60 private javax.el.ValueExpression binding;
61 private javax.el.ValueExpression label;
62 private javax.el.ValueExpression immediate;
63 private javax.el.ValueExpression transition;
64 private javax.el.ValueExpression renderedPartially;
65
66 @Override
67 public int doStartTag() throws JspException {
68
69 menuCommandTag = new MenuItemTag();
70 menuCommandTag.setPageContext(pageContext);
71 menuCommandTag.setParent(getParent());
72 if (rendered != null) {
73 menuCommandTag.setRendered(rendered);
74 }
75 if (action != null) {
76 menuCommandTag.setAction(action);
77 }
78 if (actionListener != null) {
79 menuCommandTag.setActionListener(actionListener);
80 }
81 if (onclick != null) {
82 menuCommandTag.setOnclick(onclick);
83 }
84 if (link != null) {
85 menuCommandTag.setLink(link);
86 }
87 if (disabled != null) {
88 menuCommandTag.setDisabled(disabled);
89 }
90 if (binding != null) {
91 menuCommandTag.setBinding(binding);
92 }
93 if (label != null) {
94 menuCommandTag.setLabel(label);
95 }
96 if (immediate != null) {
97 menuCommandTag.setImmediate(immediate);
98 }
99 if (transition != null) {
100 menuCommandTag.setTransition(transition);
101 }
102 if (renderedPartially != null) {
103 menuCommandTag.setRenderedPartially(renderedPartially);
104 }
105 menuCommandTag.doStartTag();
106
107 facetTag = new FacetTag();
108 facetTag.setPageContext(pageContext);
109 facetTag.setParent(menuCommandTag);
110 facetTag.setName(Facets.ITEMS);
111
112 facetTag.doStartTag();
113 selectBooleanCheckbox = new SelectBooleanCheckboxTag();
114 selectBooleanCheckbox.setPageContext(pageContext);
115 if (value != null) {
116 selectBooleanCheckbox.setValue(value);
117 }
118 selectBooleanCheckbox.setParent(facetTag);
119 selectBooleanCheckbox.doStartTag();
120 return super.doStartTag();
121 }
122
123 @Override
124 public int doEndTag() throws JspException {
125
126 if (renderedPartially == null) {
127
128 UIComponent selectBooleanComponent = selectBooleanCheckbox.getComponentInstance();
129 UICommandBase command = (UICommandBase) menuCommandTag.getComponentInstance();
130 javax.el.ValueExpression expression = selectBooleanComponent.getValueExpression(Attributes.RENDERED_PARTIALLY);
131 if (expression != null) {
132 command.setValueExpression(Attributes.RENDERED_PARTIALLY, expression);
133 } else {
134 Object renderedPartially = selectBooleanComponent.getAttributes().get(Attributes.RENDERED_PARTIALLY);
135 command.setRenderedPartially(StringUtils.split((String) renderedPartially, ", "));
136 }
137 }
138
139 selectBooleanCheckbox.doEndTag();
140 facetTag.doEndTag();
141 menuCommandTag.doEndTag();
142 return super.doEndTag();
143 }
144
145
146
147
148
149
150
151
152
153
154 @TagAttribute
155 @UIComponentTagAttribute(type = {}, expression = DynamicExpression.METHOD_BINDING,
156 methodReturnType = "java.lang.Object")
157 public void setAction(javax.el.MethodExpression action) {
158 this.action = action;
159 }
160
161
162
163
164
165
166
167 @TagAttribute
168 @UIComponentTagAttribute(type = {}, expression = DynamicExpression.METHOD_BINDING_REQUIRED,
169 methodSignature = "javax.faces.event.ActionEvent")
170 public void setActionListener(javax.el.MethodExpression actionListener) {
171 this.actionListener = actionListener;
172 }
173
174
175
176
177
178
179 @TagAttribute
180 @UIComponentTagAttribute()
181 public void setOnclick(javax.el.ValueExpression onclick) {
182 this.onclick = onclick;
183 }
184
185
186
187
188
189
190 @TagAttribute
191 @UIComponentTagAttribute()
192 public void setLink(javax.el.ValueExpression link) {
193 this.link = link;
194 }
195
196
197
198
199
200 @TagAttribute
201 @UIComponentTagAttribute(type = "javax.faces.component.UIComponent")
202 public void setBinding(javax.el.ValueExpression binding) throws JspException {
203 this.binding = binding;
204 }
205
206
207
208
209
210 @TagAttribute
211 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.TRUE")
212 public void setRendered(javax.el.ValueExpression rendered) {
213 this.rendered = rendered;
214 }
215
216
217
218
219 @TagAttribute()
220 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.FALSE")
221 public void setDisabled(javax.el.ValueExpression disabled) {
222 this.disabled = disabled;
223 }
224
225
226
227
228 @TagAttribute
229 @UIComponentTagAttribute(type = "java.lang.Object")
230 public void setValue(javax.el.ValueExpression value) {
231 this.value = value;
232 }
233
234
235
236
237
238 @TagAttribute
239 @UIComponentTagAttribute()
240 public void setLabel(javax.el.ValueExpression label) {
241 this.label = label;
242 }
243
244
245
246
247
248
249
250 @TagAttribute
251 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.FALSE")
252 public void setImmediate(javax.el.ValueExpression immediate) {
253 this.immediate = immediate;
254 }
255
256
257
258
259
260
261
262 @TagAttribute
263 @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.TRUE")
264 public void setTransition(javax.el.ValueExpression transition) {
265 this.transition = transition;
266 }
267
268
269
270
271 @TagAttribute
272 @UIComponentTagAttribute(type = "java.lang.String[]")
273 public void setRenderedPartially(javax.el.ValueExpression renderedPartially) {
274 this.renderedPartially = renderedPartially;
275 }
276
277 public void release() {
278 super.release();
279 rendered = null;
280 value = null;
281 action = null;
282 actionListener = null;
283 onclick = null;
284 link = null;
285 disabled = null;
286 binding = null;
287 label = null;
288 immediate = null;
289 transition = null;
290 renderedPartially = null;
291 menuCommandTag = null;
292 facetTag = null;
293 selectBooleanCheckbox = null;
294 }
295 }