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