1 package org.apache.myfaces.tobago.taglib.extension;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
21 import org.apache.myfaces.tobago.apt.annotation.Tag;
22 import org.apache.myfaces.tobago.taglib.decl.AbstractCommandTagDeclaration;
23 import org.apache.myfaces.tobago.internal.taglib.SelectBooleanCheckboxTag;
24 import org.apache.myfaces.tobago.internal.taglib.MenuItemTag;
25 import org.apache.myfaces.tobago.taglib.decl.HasBooleanValue;
26 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
27 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
28 import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
29
30 import javax.faces.webapp.FacetTag;
31 import javax.servlet.jsp.JspException;
32 import javax.servlet.jsp.tagext.BodyTagSupport;
33
34
35
36
37
38
39
40
41
42
43 @Tag(name = "menuCheckbox", tagExtraInfoClassName = "org.apache.myfaces.tobago.taglib.component.CommandTagExtraInfo")
44 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.MenuCheckboxTag")
45 public class MenuCheckboxExtensionTag extends BodyTagSupport implements AbstractCommandTagDeclaration,
46 HasIdBindingAndRendered, IsDisabled, HasBooleanValue, HasLabel {
47 private String rendered;
48 private String value;
49
50 private MenuItemTag menuCommandTag;
51 private SelectBooleanCheckboxTag selectBooleanCheckbox;
52 private FacetTag facetTag;
53 private String action;
54 private String actionListener;
55 private String onclick;
56 private String link;
57 private String disabled;
58 private String binding;
59 private String label;
60 private String immediate;
61 private String transition;
62 private String renderedPartially;
63
64 @Override
65 public int doStartTag() throws JspException {
66
67 menuCommandTag = new MenuItemTag();
68 menuCommandTag.setPageContext(pageContext);
69 menuCommandTag.setParent(getParent());
70 if (rendered != null) {
71 menuCommandTag.setRendered(rendered);
72 }
73 if (action != null) {
74 menuCommandTag.setAction(action);
75 }
76 if (actionListener != null) {
77 menuCommandTag.setActionListener(actionListener);
78 }
79 if (onclick != null) {
80 menuCommandTag.setOnclick(onclick);
81 }
82 if (link != null) {
83 menuCommandTag.setLink(link);
84 }
85 if (disabled != null) {
86 menuCommandTag.setDisabled(disabled);
87 }
88 if (binding != null) {
89 menuCommandTag.setBinding(binding);
90 }
91 if (label != null) {
92 menuCommandTag.setLabel(label);
93 }
94 if (immediate != null) {
95 menuCommandTag.setImmediate(immediate);
96 }
97 if (transition != null) {
98 menuCommandTag.setTransition(transition);
99 }
100 if (renderedPartially != null) {
101 menuCommandTag.setRenderedPartially(renderedPartially);
102 }
103 menuCommandTag.doStartTag();
104
105 facetTag = new FacetTag();
106 facetTag.setPageContext(pageContext);
107 facetTag.setParent(menuCommandTag);
108 facetTag.setName(org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS);
109
110 facetTag.doStartTag();
111 selectBooleanCheckbox = new SelectBooleanCheckboxTag();
112 selectBooleanCheckbox.setPageContext(pageContext);
113 if (value != null) {
114 selectBooleanCheckbox.setValue(value);
115 }
116 selectBooleanCheckbox.setParent(facetTag);
117 selectBooleanCheckbox.doStartTag();
118 return super.doStartTag();
119 }
120
121 @Override
122 public int doEndTag() throws JspException {
123 selectBooleanCheckbox.doEndTag();
124 facetTag.doEndTag();
125 menuCommandTag.doEndTag();
126 return super.doEndTag();
127 }
128
129 public void setAction(String action) {
130 this.action = action;
131 }
132
133 public void setActionListener(String actionListener) {
134 this.actionListener = actionListener;
135 }
136
137 public void setOnclick(String onclick) {
138 this.onclick = onclick;
139 }
140
141 public void setLink(String navigate) {
142 this.link = navigate;
143 }
144
145 public void setBinding(String binding) throws JspException {
146 this.binding = binding;
147 }
148
149 public void setRendered(String rendered) {
150 this.rendered = rendered;
151 }
152
153 public void setDisabled(String disabled) {
154 this.disabled = disabled;
155 }
156
157 public void setValue(String value) {
158 this.value = value;
159 }
160
161 public void setLabel(String label) {
162 this.label = label;
163 }
164
165 public void setImmediate(String immediate) {
166 this.immediate = immediate;
167 }
168
169 public void setTransition(String transition) {
170 this.transition = transition;
171 }
172
173 public void setRenderedPartially(String renderedPartially) {
174 this.renderedPartially = renderedPartially;
175 }
176
177 public void release() {
178 super.release();
179 rendered = null;
180 value = null;
181 action = null;
182 actionListener = null;
183 onclick = null;
184 link = null;
185 disabled = null;
186 binding = null;
187 label = null;
188 immediate = null;
189 transition = null;
190 renderedPartially = null;
191 menuCommandTag = null;
192 facetTag = null;
193 selectBooleanCheckbox = null;
194 }
195 }