View Javadoc

1   package org.apache.myfaces.tobago.taglib.extension;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
21  import org.apache.myfaces.tobago.apt.annotation.Tag;
22  import org.apache.myfaces.tobago.internal.taglib.SelectManyCheckboxTag;
23  import org.apache.myfaces.tobago.taglib.decl.HasBinding;
24  import org.apache.myfaces.tobago.taglib.decl.HasConverter;
25  import org.apache.myfaces.tobago.taglib.decl.HasConverterMessage;
26  import org.apache.myfaces.tobago.taglib.decl.HasId;
27  import org.apache.myfaces.tobago.taglib.decl.HasLabel;
28  import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
29  import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
30  import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
31  import org.apache.myfaces.tobago.taglib.decl.HasRenderRange;
32  import org.apache.myfaces.tobago.taglib.decl.HasRequiredMessage;
33  import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
34  import org.apache.myfaces.tobago.taglib.decl.HasTip;
35  import org.apache.myfaces.tobago.taglib.decl.HasValidator;
36  import org.apache.myfaces.tobago.taglib.decl.HasValidatorMessage;
37  import org.apache.myfaces.tobago.taglib.decl.HasValue;
38  import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
39  import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
40  import org.apache.myfaces.tobago.taglib.decl.IsFocus;
41  import org.apache.myfaces.tobago.taglib.decl.IsInline;
42  import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
43  import org.apache.myfaces.tobago.taglib.decl.IsRendered;
44  import org.apache.myfaces.tobago.taglib.decl.IsRequired;
45  
46  import javax.servlet.jsp.JspException;
47  import javax.servlet.jsp.tagext.BodyTagSupport;
48  
49  /**
50   * Render a group of checkboxes.
51   */
52  @Tag(name = "selectManyCheckbox")
53  @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.internal.taglib.SelectManyCheckboxTag")
54  public class SelectManyCheckboxExtensionTag extends BodyTagSupport
55      implements HasId, HasValue, HasValueChangeListener, IsDisabled, IsInline,
56      HasLabel, HasLabelWidth, IsRendered, HasBinding, HasTip, HasConverter, HasValidator, HasOnchange,
57      HasValidatorMessage, HasRequiredMessage, HasConverterMessage,
58      IsReadonly, HasMarkup, IsFocus, IsRequired, HasTabIndex, HasRenderRange {
59  
60    private String required;
61    private String value;
62    private String valueChangeListener;
63    private String disabled;
64    private String readonly;
65    private String onchange;
66    private String inline;
67    private String label;
68    private String rendered;
69    private String binding;
70    private String tip;
71    //private String height;
72    private String converter;
73    private String validator;
74    private String labelWidth;
75    private String markup;
76    private String tabIndex;
77    private String focus;
78    private String renderRange;
79    private String validatorMessage;
80    private String converterMessage;
81    private String requiredMessage;
82  
83    private LabelExtensionTag labelTag;
84    private SelectManyCheckboxTag selectManyCheckboxTag;
85  
86    @Override
87    public int doStartTag() throws JspException {
88  
89      labelTag = new LabelExtensionTag();
90      labelTag.setPageContext(pageContext);
91      labelTag.setRows("*");
92      if (label != null) {
93        labelTag.setValue(label);
94      }
95      if (tip != null) {
96        labelTag.setTip(tip);
97      }
98      if (rendered != null) {
99        labelTag.setRendered(rendered);
100     }
101     if (labelWidth != null) {
102       labelTag.setColumns(labelWidth + ";*");
103     }
104     if (markup != null) {
105       labelTag.setMarkup(markup);
106     }
107     labelTag.setParent(getParent());
108     labelTag.doStartTag();
109 
110     selectManyCheckboxTag = new SelectManyCheckboxTag();
111     selectManyCheckboxTag.setPageContext(pageContext);
112     if (value != null) {
113       selectManyCheckboxTag.setValue(value);
114     }
115     if (valueChangeListener != null) {
116       selectManyCheckboxTag.setValueChangeListener(valueChangeListener);
117     }
118     if (binding != null) {
119       selectManyCheckboxTag.setBinding(binding);
120     }
121     if (onchange != null) {
122       selectManyCheckboxTag.setOnchange(onchange);
123     }
124     if (validator != null) {
125       selectManyCheckboxTag.setValidator(validator);
126     }
127     if (converter != null) {
128       selectManyCheckboxTag.setConverter(converter);
129     }
130     if (disabled != null) {
131       selectManyCheckboxTag.setDisabled(disabled);
132     }
133     if (inline != null) {
134       selectManyCheckboxTag.setInline(inline);
135     }
136     if (focus != null) {
137       selectManyCheckboxTag.setFocus(focus);
138     }
139     if (id != null) {
140       selectManyCheckboxTag.setId(id);
141     }
142     /*if (height != null) {
143       selectManyCheckboxTag.setHeight(height);
144     }*/
145     if (readonly != null) {
146       selectManyCheckboxTag.setReadonly(readonly);
147     }
148     if (required != null) {
149       selectManyCheckboxTag.setRequired(required);
150     }
151     if (markup != null) {
152       selectManyCheckboxTag.setMarkup(markup);
153     }
154     if (renderRange != null) {
155       selectManyCheckboxTag.setRenderRange(renderRange);
156     }
157     if (tabIndex != null) {
158       selectManyCheckboxTag.setTabIndex(tabIndex);
159     }
160     if (validatorMessage != null) {
161       selectManyCheckboxTag.setValidatorMessage(validatorMessage);
162     }
163     if (converterMessage != null) {
164       selectManyCheckboxTag.setConverterMessage(converterMessage);
165     }
166     if (requiredMessage != null) {
167       selectManyCheckboxTag.setRequiredMessage(requiredMessage);
168     }
169 
170     selectManyCheckboxTag.setParent(labelTag);
171     selectManyCheckboxTag.doStartTag();
172 
173     return super.doStartTag();
174   }
175 
176   @Override
177   public int doEndTag() throws JspException {
178     selectManyCheckboxTag.doEndTag();
179     labelTag.doEndTag();
180     return super.doEndTag();
181   }
182 
183   @Override
184   public void release() {
185     super.release();
186     binding = null;
187     onchange = null;
188     disabled = null;
189     inline = null;
190     label = null;
191     labelWidth = null;
192     //height = null;
193     readonly = null;
194     rendered = null;
195     converter = null;
196     validator = null;
197     required = null;
198     tip = null;
199     value = null;
200     valueChangeListener = null;
201     markup = null;
202     tabIndex = null;
203     selectManyCheckboxTag = null;
204     labelTag = null;
205     focus = null;
206     renderRange = null;
207     validatorMessage = null;
208     converterMessage = null;
209     requiredMessage = null;
210   }
211 
212   public void setRequired(String required) {
213     this.required = required;
214   }
215 
216   public void setValue(String value) {
217     this.value = value;
218   }
219 
220   public void setValueChangeListener(String valueChangeListener) {
221     this.valueChangeListener = valueChangeListener;
222   }
223 
224   public void setDisabled(String disabled) {
225     this.disabled = disabled;
226   }
227 
228   public void setReadonly(String readonly) {
229     this.readonly = readonly;
230   }
231 
232   public void setOnchange(String onchange) {
233     this.onchange = onchange;
234   }
235 
236   public void setInline(String inline) {
237     this.inline = inline;
238   }
239 
240   public void setLabel(String label) {
241     this.label = label;
242   }
243 
244   /*public void setHeight(String height) {
245     this.height = height;
246   } */
247 
248   public void setValidator(String validator) {
249     this.validator = validator;
250   }
251 
252   public void setConverter(String converter) {
253     this.converter = converter;
254   }
255 
256   public void setRendered(String rendered) {
257     this.rendered = rendered;
258   }
259 
260   public void setBinding(String binding) {
261     this.binding = binding;
262   }
263 
264   public void setTip(String tip) {
265     this.tip = tip;
266   }
267 
268   public void setLabelWidth(String labelWidth) {
269     this.labelWidth = labelWidth;
270   }
271 
272   public void setMarkup(String markup) {
273     this.markup = markup;
274   }
275 
276   public void setTabIndex(String tabIndex) {
277     this.tabIndex = tabIndex;
278   }
279 
280   public void setFocus(String focus) {
281     this.focus = focus;
282   }
283 
284   public void setRenderRange(String renderRange) {
285     this.renderRange = renderRange;
286   }
287 
288   public void setValidatorMessage(String validatorMessage) {
289     this.validatorMessage = validatorMessage;
290   }
291 
292   public void setConverterMessage(String converterMessage) {
293     this.converterMessage = converterMessage;
294   }
295 
296   public void setRequiredMessage(String requiredMessage) {
297     this.requiredMessage = requiredMessage;
298   }
299 
300 
301 }
302