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.IsReadonly;
037    import org.apache.myfaces.tobago.taglib.decl.IsRendered;
038    import org.apache.myfaces.tobago.taglib.decl.IsRequired;
039    
040    import javax.servlet.jsp.JspException;
041    import javax.servlet.jsp.tagext.BodyTagSupport;
042    
043    /*
044     * Created by IntelliJ IDEA.
045     * User: bommel
046     * Date: 17.12.2005
047     * Time: 08:24:21
048     */
049    /**
050     * Render a single selection option listbox.
051     */
052    @Tag(name = "selectOneListbox")
053    @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectOneListboxTag")
054    public class SelectOneListboxExtensionTag
055        extends BodyTagSupport implements HasId, HasValue, HasValueChangeListener, IsDisabled,
056        HasLabel, HasLabelWidth, IsReadonly, HasOnchange, IsRendered,
057        HasBinding, HasDeprecatedHeight, HasTip , IsRequired, HasConverter, HasValidator, HasTabIndex {
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 tabIndex;
074    
075      private LabelExtensionTag labelTag;
076      private SelectOneListboxTag selectOneListboxTag;
077    
078      @Override
079      public int doStartTag() throws JspException {
080    
081        labelTag = new LabelExtensionTag();
082        labelTag.setPageContext(pageContext);
083        labelTag.setRows("*");
084        if (label != null) {
085          labelTag.setValue(label);
086        }
087        if (tip != null) {
088          labelTag.setTip(tip);
089        }
090        if (rendered != null) {
091          labelTag.setRendered(rendered);
092        }
093        if (labelWidth != null) {
094          labelTag.setColumns(labelWidth + ";*");
095        }
096        labelTag.setParent(getParent());
097        labelTag.doStartTag();
098    
099        selectOneListboxTag = new SelectOneListboxTag();
100        selectOneListboxTag.setPageContext(pageContext);
101        if (value != null) {
102          selectOneListboxTag.setValue(value);
103        }
104        if (valueChangeListener != null) {
105          selectOneListboxTag.setValueChangeListener(valueChangeListener);
106        }
107        if (binding != null) {
108          selectOneListboxTag.setBinding(binding);
109        }
110        if (onchange != null) {
111          selectOneListboxTag.setOnchange(onchange);
112        }
113        if (validator != null) {
114          selectOneListboxTag.setValidator(validator);
115        }
116        if (converter != null) {
117          selectOneListboxTag.setConverter(converter);
118        }
119        if (disabled != null) {
120          selectOneListboxTag.setDisabled(disabled);
121        }
122        if (inline != null) {
123          selectOneListboxTag.setFocus(inline);
124        }
125        if (id != null) {
126          selectOneListboxTag.setId(id);
127        }
128        if (height != null) {
129          selectOneListboxTag.setHeight(height);
130        }
131        if (readonly != null) {
132          selectOneListboxTag.setReadonly(readonly);
133        }
134        if (required != null) {
135          selectOneListboxTag.setRequired(required);
136        }
137        if (tabIndex != null) {
138          selectOneListboxTag.setTabIndex(tabIndex);
139        }
140        selectOneListboxTag.setParent(labelTag);
141        selectOneListboxTag.doStartTag();
142    
143        return super.doStartTag();
144      }
145    
146      @Override
147      public int doEndTag() throws JspException {
148        selectOneListboxTag.doEndTag();
149        labelTag.doEndTag();
150        return super.doEndTag();
151      }
152    
153      @Override
154      public void release() {
155        super.release();
156        binding = null;
157        onchange = null;
158        disabled = null;
159        inline = null;
160        labelWidth = null;
161        label = null;
162        height = null;
163        readonly = null;
164        rendered = null;
165        converter = null;
166        validator = null;
167        required = null;
168        tip = null;
169        value = null;
170        valueChangeListener = null;
171        tabIndex = null;
172        selectOneListboxTag = null;
173        labelTag = 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    }