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