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.taglib.decl.HasId;
021    import org.apache.myfaces.tobago.taglib.decl.HasValue;
022    import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
023    import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
024    import org.apache.myfaces.tobago.taglib.decl.HasDeprecatedHeight;
025    import org.apache.myfaces.tobago.taglib.decl.IsInline;
026    import org.apache.myfaces.tobago.taglib.decl.HasLabel;
027    import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
028    import org.apache.myfaces.tobago.taglib.decl.IsRendered;
029    import org.apache.myfaces.tobago.taglib.decl.HasBinding;
030    import org.apache.myfaces.tobago.taglib.decl.HasTip;
031    import org.apache.myfaces.tobago.taglib.decl.HasConverter;
032    import org.apache.myfaces.tobago.taglib.decl.HasValidator;
033    import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
034    import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
035    import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
036    import org.apache.myfaces.tobago.taglib.decl.IsFocus;
037    import org.apache.myfaces.tobago.taglib.decl.IsRequired;
038    import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
039    import org.apache.myfaces.tobago.taglib.decl.HasRenderRange;
040    import org.apache.myfaces.tobago.taglib.component.SelectManyCheckboxTag;
041    import org.apache.myfaces.tobago.apt.annotation.Tag;
042    import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
043    
044    import javax.servlet.jsp.tagext.BodyTagSupport;
045    import javax.servlet.jsp.JspException;
046    
047    /**
048     * Render a group of checkboxes.
049     */
050    @Tag(name = "selectManyCheckbox")
051    @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectManyCheckboxTag")
052    public class SelectManyCheckboxExtensionTag extends BodyTagSupport
053        implements HasId, HasValue, HasValueChangeListener, IsDisabled, HasDeprecatedHeight, IsInline,
054        HasLabel, HasLabelWidth, IsRendered, HasBinding, HasTip, HasConverter, HasValidator, HasOnchange,
055        IsReadonly, HasMarkup, IsFocus, IsRequired, HasTabIndex, HasRenderRange {
056    
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      private String markup;
073      private String tabIndex;
074      private String focus;
075      private String renderRange;
076    
077      private LabelExtensionTag labelTag;
078      private SelectManyCheckboxTag selectManyCheckboxTag;
079    
080      @Override
081      public int doStartTag() throws JspException {
082    
083        labelTag = new LabelExtensionTag();
084        labelTag.setPageContext(pageContext);
085        labelTag.setRows("*");
086        if (label != null) {
087          labelTag.setValue(label);
088        }
089        if (tip != null) {
090          labelTag.setTip(tip);
091        }
092        if (rendered != null) {
093          labelTag.setRendered(rendered);
094        }
095        if (labelWidth != null) {
096          labelTag.setColumns(labelWidth + ";*");
097        }
098        if (markup != null) {
099          labelTag.setMarkup(markup);
100        }
101        labelTag.setParent(getParent());
102        labelTag.doStartTag();
103    
104        selectManyCheckboxTag = new SelectManyCheckboxTag();
105        selectManyCheckboxTag.setPageContext(pageContext);
106        if (value != null) {
107          selectManyCheckboxTag.setValue(value);
108        }
109        if (valueChangeListener != null) {
110          selectManyCheckboxTag.setValueChangeListener(valueChangeListener);
111        }
112        if (binding != null) {
113          selectManyCheckboxTag.setBinding(binding);
114        }
115        if (onchange != null) {
116          selectManyCheckboxTag.setOnchange(onchange);
117        }
118        if (validator != null) {
119          selectManyCheckboxTag.setValidator(validator);
120        }
121        if (converter != null) {
122          selectManyCheckboxTag.setConverter(converter);
123        }
124        if (disabled != null) {
125          selectManyCheckboxTag.setDisabled(disabled);
126        }
127        if (inline != null) {
128          selectManyCheckboxTag.setInline(inline);
129        }
130        if (focus != null) {
131          selectManyCheckboxTag.setFocus(focus);
132        }
133        if (id != null) {
134          selectManyCheckboxTag.setId(id);
135        }
136        if (height != null) {
137          selectManyCheckboxTag.setHeight(height);
138        }
139        if (readonly != null) {
140          selectManyCheckboxTag.setReadonly(readonly);
141        }
142        if (required != null) {
143          selectManyCheckboxTag.setRequired(required);
144        }
145        if (markup != null) {
146          selectManyCheckboxTag.setMarkup(markup);
147        }
148        if (renderRange != null) {
149          selectManyCheckboxTag.setRenderRange(renderRange);
150        }
151        if (tabIndex != null) {
152          selectManyCheckboxTag.setTabIndex(tabIndex);
153        }
154        selectManyCheckboxTag.setParent(labelTag);
155        selectManyCheckboxTag.doStartTag();
156    
157        return super.doStartTag();
158      }
159    
160      @Override
161      public int doEndTag() throws JspException {
162        selectManyCheckboxTag.doEndTag();
163        labelTag.doEndTag();
164        return super.doEndTag();
165      }
166    
167      @Override
168      public void release() {
169        super.release();
170        binding = null;
171        onchange = null;
172        disabled = null;
173        inline = null;
174        label = null;
175        labelWidth = null;
176        height = null;
177        readonly = null;
178        rendered = null;
179        converter = null;
180        validator = null;
181        required = null;
182        tip = null;
183        value = null;
184        valueChangeListener = null;
185        markup = null;
186        tabIndex = null;
187        selectManyCheckboxTag = null;
188        labelTag = null;
189        focus = null;
190        renderRange = 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    
265      public void setRenderRange(String renderRange) {
266        this.renderRange = renderRange;
267      }
268    }
269