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.SelectManyListboxTag;
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.HasTabIndex;
034 import org.apache.myfaces.tobago.taglib.decl.HasTip;
035 import org.apache.myfaces.tobago.taglib.decl.HasValidator;
036 import org.apache.myfaces.tobago.taglib.decl.HasValue;
037 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
038 import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
039 import org.apache.myfaces.tobago.taglib.decl.IsFocus;
040 import org.apache.myfaces.tobago.taglib.decl.IsInline;
041 import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
042 import org.apache.myfaces.tobago.taglib.decl.IsRendered;
043 import org.apache.myfaces.tobago.taglib.decl.IsRequired;
044 import org.apache.myfaces.tobago.util.Deprecation;
045
046 import javax.servlet.jsp.JspException;
047 import javax.servlet.jsp.tagext.BodyTagSupport;
048
049 /*
050 * Date: 16.12.2005
051 * Time: 19:12:33
052 */
053
054 /**
055 * Render a group of checkboxes.
056 */
057
058 @Tag(name = "selectManyListbox")
059 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectManyListboxTag")
060 public class SelectManyListboxExtensionTag extends BodyTagSupport
061 implements HasId, HasValue, HasValueChangeListener, IsDisabled, HasDeprecatedHeight, IsInline,
062 HasLabel, HasLabelWidth, IsRendered, HasBinding, HasTip, HasConverter, HasValidator, HasOnchange,
063 IsReadonly, HasMarkup, IsFocus, IsRequired, HasTabIndex {
064
065 private String required;
066 private String value;
067 private String valueChangeListener;
068 private String disabled;
069 private String readonly;
070 private String onchange;
071 private String inline;
072 private String label;
073 private String rendered;
074 private String binding;
075 private String tip;
076 private String height;
077 private String converter;
078 private String validator;
079 private String labelWidth;
080 private String markup;
081 private String tabIndex;
082 private String focus;
083
084 private LabelExtensionTag labelTag;
085 private SelectManyListboxTag selectManyListboxTag;
086
087 @Override
088 public int doStartTag() throws JspException {
089
090 labelTag = new LabelExtensionTag();
091 labelTag.setPageContext(pageContext);
092 labelTag.setRows("*");
093 if (label != null) {
094 labelTag.setValue(label);
095 }
096 if (tip != null) {
097 labelTag.setTip(tip);
098 }
099 if (rendered != null) {
100 labelTag.setRendered(rendered);
101 }
102 if (labelWidth != null) {
103 labelTag.setColumns(labelWidth + ";*");
104 }
105 if (markup != null) {
106 labelTag.setMarkup(markup);
107 }
108 labelTag.setParent(getParent());
109 labelTag.doStartTag();
110
111 selectManyListboxTag = new SelectManyListboxTag();
112 selectManyListboxTag.setPageContext(pageContext);
113 if (value != null) {
114 selectManyListboxTag.setValue(value);
115 }
116 if (valueChangeListener != null) {
117 selectManyListboxTag.setValueChangeListener(valueChangeListener);
118 }
119 if (binding != null) {
120 selectManyListboxTag.setBinding(binding);
121 }
122 if (onchange != null) {
123 selectManyListboxTag.setOnchange(onchange);
124 }
125 if (validator != null) {
126 selectManyListboxTag.setValidator(validator);
127 }
128 if (converter != null) {
129 selectManyListboxTag.setConverter(converter);
130 }
131 if (disabled != null) {
132 selectManyListboxTag.setDisabled(disabled);
133 }
134 if (inline != null) {
135 selectManyListboxTag.setInline(inline);
136 }
137 if (focus != null) {
138 selectManyListboxTag.setFocus(focus);
139 }
140 if (id != null) {
141 selectManyListboxTag.setId(id);
142 }
143 if (height != null) {
144 selectManyListboxTag.setHeight(height);
145 }
146 if (readonly != null) {
147 selectManyListboxTag.setReadonly(readonly);
148 }
149 if (required != null) {
150 selectManyListboxTag.setRequired(required);
151 }
152 if (markup != null) {
153 selectManyListboxTag.setMarkup(markup);
154 }
155 if (tabIndex != null) {
156 selectManyListboxTag.setTabIndex(tabIndex);
157 }
158 selectManyListboxTag.setParent(labelTag);
159 selectManyListboxTag.doStartTag();
160
161 return super.doStartTag();
162 }
163
164 @Override
165 public int doEndTag() throws JspException {
166 selectManyListboxTag.doEndTag();
167 labelTag.doEndTag();
168 return super.doEndTag();
169 }
170
171 @Override
172 public void release() {
173 super.release();
174 binding = null;
175 onchange = null;
176 disabled = null;
177 inline = null;
178 label = null;
179 labelWidth = null;
180 height = null;
181 readonly = null;
182 rendered = null;
183 converter = null;
184 validator = null;
185 required = null;
186 tip = null;
187 value = null;
188 valueChangeListener = null;
189 markup = null;
190 tabIndex = null;
191 selectManyListboxTag = null;
192 labelTag = null;
193 focus = 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 }