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