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