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