001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.taglib.extension;
021
022 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
023 import org.apache.myfaces.tobago.apt.annotation.Tag;
024 import org.apache.myfaces.tobago.taglib.component.SelectBooleanCheckboxTag;
025 import org.apache.myfaces.tobago.taglib.component.TobagoTagDeclaration;
026 import org.apache.myfaces.tobago.taglib.decl.HasBooleanValue;
027 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
028 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
029 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
030 import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
031 import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
032 import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
033 import org.apache.myfaces.tobago.taglib.decl.HasTip;
034 import org.apache.myfaces.tobago.taglib.decl.HasValidator;
035 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
036 import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
037 import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
038 //import org.apache.myfaces.tobago.taglib.decl.IsRequired;
039 import org.apache.myfaces.tobago.taglib.decl.IsFocus;
040
041 import javax.servlet.jsp.JspException;
042 import javax.servlet.jsp.tagext.BodyTagSupport;
043
044 /*
045 * Date: Oct 7, 2006
046 * Time: 9:13:21 AM
047 */
048 /**
049 * Renders a checkbox.
050 */
051 @Tag(name = "selectBooleanCheckbox")
052 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectBooleanCheckboxTag")
053 public class SelectBooleanCheckboxExtensionTag extends BodyTagSupport implements TobagoTagDeclaration,
054 HasValidator, HasOnchange, HasValueChangeListener, HasIdBindingAndRendered, HasLabel,
055 HasBooleanValue, HasLabelWidth, IsDisabled, HasTip, IsReadonly, HasMarkup, HasTabIndex, //IsRequired
056 IsFocus {
057
058 private String value;
059 private String valueChangeListener;
060 private String disabled;
061 private String readonly;
062 private String onchange;
063 private String label;
064 private String rendered;
065 private String binding;
066 private String tip;
067 private String converter;
068 private String validator;
069 private String labelWidth;
070 private String markup;
071 private String tabIndex;
072 //private String required;
073 private String focus;
074
075 private LabelExtensionTag labelTag;
076 private SelectBooleanCheckboxTag selectBooleanCheckboxTag;
077
078 @Override
079 public int doStartTag() throws JspException {
080
081 labelTag = new LabelExtensionTag();
082 labelTag.setPageContext(pageContext);
083 if (label != null) {
084 labelTag.setValue(label);
085 }
086 if (tip != null) {
087 labelTag.setTip(tip);
088 }
089 if (rendered != null) {
090 labelTag.setRendered(rendered);
091 }
092 if (labelWidth != null) {
093 labelTag.setColumns(labelWidth + ";*");
094 }
095 if (markup != null) {
096 labelTag.setMarkup(markup);
097 }
098 labelTag.setParent(getParent());
099 labelTag.doStartTag();
100
101 selectBooleanCheckboxTag = new SelectBooleanCheckboxTag();
102 selectBooleanCheckboxTag.setPageContext(pageContext);
103 if (value != null) {
104 selectBooleanCheckboxTag.setValue(value);
105 }
106 if (valueChangeListener != null) {
107 selectBooleanCheckboxTag.setValueChangeListener(valueChangeListener);
108 }
109 if (binding != null) {
110 selectBooleanCheckboxTag.setBinding(binding);
111 }
112 if (onchange != null) {
113 selectBooleanCheckboxTag.setOnchange(onchange);
114 }
115 if (validator != null) {
116 selectBooleanCheckboxTag.setValidator(validator);
117 }
118 if (converter != null) {
119 selectBooleanCheckboxTag.setConverter(converter);
120 }
121 if (disabled != null) {
122 selectBooleanCheckboxTag.setDisabled(disabled);
123 }
124
125 if (id != null) {
126 selectBooleanCheckboxTag.setId(id);
127 }
128
129 if (readonly != null) {
130 selectBooleanCheckboxTag.setReadonly(readonly);
131 }
132
133 if (focus != null) {
134 selectBooleanCheckboxTag.setFocus(focus);
135 }
136
137 //if (required != null) {
138 // selectBooleanCheckboxTag.setRequired(required);
139 //}
140 // TODO item Label
141 //if (itemLabel != null) {
142 // selectOneRadioTag.setLabel(itemLabel);
143 //}
144
145 if (markup != null) {
146 selectBooleanCheckboxTag.setMarkup(markup);
147 }
148 if (tabIndex != null) {
149 selectBooleanCheckboxTag.setTabIndex(tabIndex);
150 }
151 selectBooleanCheckboxTag.setParent(labelTag);
152 selectBooleanCheckboxTag.doStartTag();
153
154 return super.doStartTag();
155 }
156
157 @Override
158 public int doEndTag() throws JspException {
159 selectBooleanCheckboxTag.doEndTag();
160 labelTag.doEndTag();
161 return super.doEndTag();
162 }
163
164 @Override
165 public void release() {
166 super.release();
167 binding = null;
168 onchange = null;
169 disabled = null;
170 label = null;
171 labelWidth = null;
172 readonly = null;
173 rendered = null;
174 converter = null;
175 validator = null;
176 tip = null;
177 value = null;
178 valueChangeListener = null;
179 markup = null;
180 tabIndex = null;
181 focus = null;
182 //required = null;
183 selectBooleanCheckboxTag = null;
184 labelTag = null;
185 }
186
187 public void setValue(String value) {
188 this.value = value;
189 }
190
191 public void setValueChangeListener(String valueChangeListener) {
192 this.valueChangeListener = valueChangeListener;
193 }
194
195 public void setDisabled(String disabled) {
196 this.disabled = disabled;
197 }
198
199 public void setReadonly(String readonly) {
200 this.readonly = readonly;
201 }
202
203 public void setOnchange(String onchange) {
204 this.onchange = onchange;
205 }
206
207 public void setLabel(String label) {
208 this.label = label;
209 }
210
211 public void setValidator(String validator) {
212 this.validator = validator;
213 }
214
215 public void setConverter(String converter) {
216 this.converter = converter;
217 }
218
219 public void setRendered(String rendered) {
220 this.rendered = rendered;
221 }
222
223 public void setBinding(String binding) {
224 this.binding = binding;
225 }
226
227 public void setTip(String tip) {
228 this.tip = tip;
229 }
230
231 public void setLabelWidth(String labelWidth) {
232 this.labelWidth = labelWidth;
233 }
234
235 public void setMarkup(String markup) {
236 this.markup = markup;
237 }
238
239 public void setTabIndex(String tabIndex) {
240 this.tabIndex = tabIndex;
241 }
242
243 public void setFocus(String focus) {
244 this.focus = focus;
245 }
246
247 //public void setRequired(String required) {
248 // this.required = required;
249 //}
250 }