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.SelectManyCheckboxTag;
025 import org.apache.myfaces.tobago.taglib.decl.HasBinding;
026 import org.apache.myfaces.tobago.taglib.decl.HasConverter;
027 import org.apache.myfaces.tobago.taglib.decl.HasDeprecatedHeight;
028 import org.apache.myfaces.tobago.taglib.decl.HasId;
029 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
030 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
031 import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
032 import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
033 import org.apache.myfaces.tobago.taglib.decl.HasRenderRange;
034 import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
035 import org.apache.myfaces.tobago.taglib.decl.HasTip;
036 import org.apache.myfaces.tobago.taglib.decl.HasValidator;
037 import org.apache.myfaces.tobago.taglib.decl.HasValue;
038 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
039 import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
040 import org.apache.myfaces.tobago.taglib.decl.IsFocus;
041 import org.apache.myfaces.tobago.taglib.decl.IsInline;
042 import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
043 import org.apache.myfaces.tobago.taglib.decl.IsRendered;
044 import org.apache.myfaces.tobago.taglib.decl.IsRequired;
045 import org.apache.myfaces.tobago.util.Deprecation;
046
047 import javax.servlet.jsp.JspException;
048 import javax.servlet.jsp.tagext.BodyTagSupport;
049
050 /**
051 * Render a group of checkboxes.
052 */
053 @Tag(name = "selectManyCheckbox")
054 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectManyCheckboxTag")
055 public class SelectManyCheckboxExtensionTag extends BodyTagSupport
056 implements HasId, HasValue, HasValueChangeListener, IsDisabled, HasDeprecatedHeight, IsInline,
057 HasLabel, HasLabelWidth, IsRendered, HasBinding, HasTip, HasConverter, HasValidator, HasOnchange,
058 IsReadonly, HasMarkup, IsFocus, IsRequired, HasTabIndex, HasRenderRange {
059
060 private String required;
061 private String value;
062 private String valueChangeListener;
063 private String disabled;
064 private String readonly;
065 private String onchange;
066 private String inline;
067 private String label;
068 private String rendered;
069 private String binding;
070 private String tip;
071 private String height;
072 private String converter;
073 private String validator;
074 private String labelWidth;
075 private String markup;
076 private String tabIndex;
077 private String focus;
078 private String renderRange;
079
080 private LabelExtensionTag labelTag;
081 private SelectManyCheckboxTag selectManyCheckboxTag;
082
083 @Override
084 public int doStartTag() throws JspException {
085
086 labelTag = new LabelExtensionTag();
087 labelTag.setPageContext(pageContext);
088 labelTag.setRows("*");
089 if (label != null) {
090 labelTag.setValue(label);
091 }
092 if (tip != null) {
093 labelTag.setTip(tip);
094 }
095 if (rendered != null) {
096 labelTag.setRendered(rendered);
097 }
098 if (labelWidth != null) {
099 labelTag.setColumns(labelWidth + ";*");
100 }
101 if (markup != null) {
102 labelTag.setMarkup(markup);
103 }
104 labelTag.setParent(getParent());
105 labelTag.doStartTag();
106
107 selectManyCheckboxTag = new SelectManyCheckboxTag();
108 selectManyCheckboxTag.setPageContext(pageContext);
109 if (value != null) {
110 selectManyCheckboxTag.setValue(value);
111 }
112 if (valueChangeListener != null) {
113 selectManyCheckboxTag.setValueChangeListener(valueChangeListener);
114 }
115 if (binding != null) {
116 selectManyCheckboxTag.setBinding(binding);
117 }
118 if (onchange != null) {
119 selectManyCheckboxTag.setOnchange(onchange);
120 }
121 if (validator != null) {
122 selectManyCheckboxTag.setValidator(validator);
123 }
124 if (converter != null) {
125 selectManyCheckboxTag.setConverter(converter);
126 }
127 if (disabled != null) {
128 selectManyCheckboxTag.setDisabled(disabled);
129 }
130 if (inline != null) {
131 selectManyCheckboxTag.setInline(inline);
132 }
133 if (focus != null) {
134 selectManyCheckboxTag.setFocus(focus);
135 }
136 if (id != null) {
137 selectManyCheckboxTag.setId(id);
138 }
139 if (height != null) {
140 selectManyCheckboxTag.setHeight(height);
141 }
142 if (readonly != null) {
143 selectManyCheckboxTag.setReadonly(readonly);
144 }
145 if (required != null) {
146 selectManyCheckboxTag.setRequired(required);
147 }
148 if (markup != null) {
149 selectManyCheckboxTag.setMarkup(markup);
150 }
151 if (renderRange != null) {
152 selectManyCheckboxTag.setRenderRange(renderRange);
153 }
154 if (tabIndex != null) {
155 selectManyCheckboxTag.setTabIndex(tabIndex);
156 }
157 selectManyCheckboxTag.setParent(labelTag);
158 selectManyCheckboxTag.doStartTag();
159
160 return super.doStartTag();
161 }
162
163 @Override
164 public int doEndTag() throws JspException {
165 selectManyCheckboxTag.doEndTag();
166 labelTag.doEndTag();
167 return super.doEndTag();
168 }
169
170 @Override
171 public void release() {
172 super.release();
173 binding = null;
174 onchange = null;
175 disabled = null;
176 inline = null;
177 label = null;
178 labelWidth = null;
179 height = null;
180 readonly = null;
181 rendered = null;
182 converter = null;
183 validator = null;
184 required = null;
185 tip = null;
186 value = null;
187 valueChangeListener = null;
188 markup = null;
189 tabIndex = null;
190 selectManyCheckboxTag = null;
191 labelTag = null;
192 focus = null;
193 renderRange = null;
194 }
195
196 public void setRequired(String required) {
197 this.required = required;
198 }
199
200 public void setValue(String value) {
201 this.value = value;
202 }
203
204 public void setValueChangeListener(String valueChangeListener) {
205 this.valueChangeListener = valueChangeListener;
206 }
207
208 public void setDisabled(String disabled) {
209 this.disabled = disabled;
210 }
211
212 public void setReadonly(String readonly) {
213 this.readonly = readonly;
214 }
215
216 public void setOnchange(String onchange) {
217 this.onchange = onchange;
218 }
219
220 public void setInline(String inline) {
221 this.inline = inline;
222 }
223
224 public void setLabel(String label) {
225 this.label = label;
226 }
227
228 public void setHeight(String height) {
229 if (Deprecation.LOG.isWarnEnabled()) {
230 Deprecation.LOG.warn("Attribute 'height' is deprecated, "
231 + "and will removed soon! Please use a layout manager instead.");
232 }
233 this.height = height;
234 }
235
236 public void setValidator(String validator) {
237 this.validator = validator;
238 }
239
240 public void setConverter(String converter) {
241 this.converter = converter;
242 }
243
244 public void setRendered(String rendered) {
245 this.rendered = rendered;
246 }
247
248 public void setBinding(String binding) {
249 this.binding = binding;
250 }
251
252 public void setTip(String tip) {
253 this.tip = tip;
254 }
255
256 public void setLabelWidth(String labelWidth) {
257 this.labelWidth = labelWidth;
258 }
259
260 public void setMarkup(String markup) {
261 this.markup = markup;
262 }
263
264 public void setTabIndex(String tabIndex) {
265 this.tabIndex = tabIndex;
266 }
267
268 public void setFocus(String focus) {
269 this.focus = focus;
270 }
271
272 public void setRenderRange(String renderRange) {
273 this.renderRange = renderRange;
274 }
275 }
276