View Javadoc

1   package org.apache.myfaces.tobago.taglib.extension12;
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.DynamicExpression;
21  import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
22  import org.apache.myfaces.tobago.apt.annotation.Tag;
23  import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
24  import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
25  import org.apache.myfaces.tobago.internal.taglib.SelectManyCheckboxTag;
26  
27  import javax.servlet.jsp.JspException;
28  
29  /**
30   * Render a group of checkboxes.
31   */
32  @Tag(name = "selectManyCheckbox")
33  @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.internal.taglib.SelectManyCheckboxTag")
34  public class SelectManyCheckboxExtensionTag extends TobagoExtensionBodyTagSupport {
35  
36    private javax.el.ValueExpression required;
37    private javax.el.ValueExpression value;
38    private javax.el.MethodExpression valueChangeListener;
39    private javax.el.ValueExpression disabled;
40    private javax.el.ValueExpression readonly;
41    private javax.el.ValueExpression onchange;
42    private javax.el.ValueExpression inline;
43    private javax.el.ValueExpression label;
44    private javax.el.ValueExpression rendered;
45    private javax.el.ValueExpression binding;
46    private javax.el.ValueExpression tip;
47    //private javax.el.ValueExpression height;
48    private javax.el.ValueExpression converter;
49    private javax.el.MethodExpression validator;
50    private javax.el.ValueExpression labelWidth;
51    private javax.el.ValueExpression markup;
52    private javax.el.ValueExpression tabIndex;
53    private javax.el.ValueExpression focus;
54    private javax.el.ValueExpression renderRange;
55    private javax.el.ValueExpression validatorMessage;
56    private javax.el.ValueExpression converterMessage;
57    private javax.el.ValueExpression requiredMessage;
58  
59    private LabelExtensionTag labelTag;
60    private SelectManyCheckboxTag selectManyCheckboxTag;
61  
62    @Override
63    public int doStartTag() throws JspException {
64  
65      labelTag = new LabelExtensionTag();
66      labelTag.setPageContext(pageContext);
67      labelTag.setRows("*");
68      if (label != null) {
69        labelTag.setValue(label);
70      }
71      if (tip != null) {
72        labelTag.setTip(tip);
73      }
74      if (rendered != null) {
75        labelTag.setRendered(rendered);
76      }
77      if (labelWidth != null) {
78        labelTag.setColumns(createStringValueExpression(labelWidth.getExpressionString() + ";*"));
79      }
80      if (markup != null) {
81        labelTag.setMarkup(markup);
82      }
83      labelTag.setParent(getParent());
84      labelTag.doStartTag();
85  
86      selectManyCheckboxTag = new SelectManyCheckboxTag();
87      selectManyCheckboxTag.setPageContext(pageContext);
88      if (value != null) {
89        selectManyCheckboxTag.setValue(value);
90      }
91      if (valueChangeListener != null) {
92        selectManyCheckboxTag.setValueChangeListener(valueChangeListener);
93      }
94      if (binding != null) {
95        selectManyCheckboxTag.setBinding(binding);
96      }
97      if (onchange != null) {
98        selectManyCheckboxTag.setOnchange(onchange);
99      }
100     if (validator != null) {
101       selectManyCheckboxTag.setValidator(validator);
102     }
103     if (converter != null) {
104       selectManyCheckboxTag.setConverter(converter);
105     }
106     if (disabled != null) {
107       selectManyCheckboxTag.setDisabled(disabled);
108     }
109     if (inline != null) {
110       selectManyCheckboxTag.setInline(inline);
111     }
112     if (focus != null) {
113       selectManyCheckboxTag.setFocus(focus);
114     }
115     if (id != null) {
116       selectManyCheckboxTag.setId(id);
117     }
118     /*if (height != null) {
119       selectManyCheckboxTag.setHeight(height);
120     }*/
121     if (readonly != null) {
122       selectManyCheckboxTag.setReadonly(readonly);
123     }
124     if (required != null) {
125       selectManyCheckboxTag.setRequired(required);
126     }
127     if (markup != null) {
128       selectManyCheckboxTag.setMarkup(markup);
129     }
130     if (renderRange != null) {
131       selectManyCheckboxTag.setRenderRange(renderRange);
132     }
133     if (tabIndex != null) {
134       selectManyCheckboxTag.setTabIndex(tabIndex);
135     }
136     if (validatorMessage != null) {
137       selectManyCheckboxTag.setValidatorMessage(validatorMessage);
138     }
139     if (converterMessage != null) {
140       selectManyCheckboxTag.setConverterMessage(converterMessage);
141     }
142     if (requiredMessage != null) {
143       selectManyCheckboxTag.setRequiredMessage(requiredMessage);
144     }
145     selectManyCheckboxTag.setParent(labelTag);
146     selectManyCheckboxTag.doStartTag();
147 
148     return super.doStartTag();
149   }
150 
151   @Override
152   public int doEndTag() throws JspException {
153     selectManyCheckboxTag.doEndTag();
154     labelTag.doEndTag();
155     return super.doEndTag();
156   }
157 
158   @Override
159   public void release() {
160     super.release();
161     binding = null;
162     onchange = null;
163     disabled = null;
164     inline = null;
165     label = null;
166     labelWidth = null;
167     //height = null;
168     readonly = null;
169     rendered = null;
170     converter = null;
171     validator = null;
172     required = null;
173     tip = null;
174     value = null;
175     valueChangeListener = null;
176     markup = null;
177     tabIndex = null;
178     selectManyCheckboxTag = null;
179     labelTag = null;
180     focus = null;
181     renderRange = null;
182     validatorMessage = null;
183     converterMessage = null;
184     requiredMessage = null;
185   }
186 
187   /**
188    * Flag indicating that a value is required.
189    * If the value is an empty string a
190    * ValidationError occurs and a Error Message is rendered.
191    */
192   @TagAttribute
193   @UIComponentTagAttribute(type = "java.lang.Boolean")
194   public void setRequired(javax.el.ValueExpression required) {
195     this.required = required;
196   }
197 
198   /**
199    * The current value of this component.
200    */
201   @TagAttribute
202   @UIComponentTagAttribute(type = "java.lang.Object")
203   public void setValue(javax.el.ValueExpression value) {
204     this.value = value;
205   }
206 
207   /**
208    * MethodBinding representing a value change listener method
209    * that will be notified when a new value has been set for this input component.
210    * The expression must evaluate to a public method that takes a ValueChangeEvent
211    * parameter, with a return type of void.
212    *
213    * @param valueChangeListener
214    */
215   @TagAttribute
216   @UIComponentTagAttribute(
217           type = {},
218           expression = DynamicExpression.METHOD_BINDING_REQUIRED,
219           methodSignature = "javax.faces.event.ValueChangeEvent")
220   public void setValueChangeListener(javax.el.MethodExpression valueChangeListener) {
221     this.valueChangeListener = valueChangeListener;
222   }
223 
224   /**
225    * Flag indicating that this element is disabled.
226    */
227   @TagAttribute()
228   @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.FALSE")
229   public void setDisabled(javax.el.ValueExpression disabled) {
230     this.disabled = disabled;
231   }
232 
233   /**
234    * Flag indicating that this component will prohibit changes by the user.
235    */
236   @TagAttribute
237   @UIComponentTagAttribute(type = "java.lang.Boolean")
238   public void setReadonly(javax.el.ValueExpression readonly) {
239     this.readonly = readonly;
240   }
241 
242   /**
243    * Clientside script function to add to this component's onchange handler.
244    */
245   @TagAttribute
246   @UIComponentTagAttribute()
247   public void setOnchange(javax.el.ValueExpression onchange) {
248     this.onchange = onchange;
249   }
250 
251   /**
252    * Flag indicating this component should rendered as an inline element.
253    */
254   @TagAttribute
255   @UIComponentTagAttribute(type = "java.lang.Boolean")
256   public void setInline(javax.el.ValueExpression inline) {
257     this.inline = inline;
258   }
259 
260   /**
261    * Text value to display as label.
262    * If text contains an underscore the next character is used as accesskey.
263    */
264   @TagAttribute
265   @UIComponentTagAttribute()
266   public void setLabel(javax.el.ValueExpression label) {
267     this.label = label;
268   }
269 
270   /*public void setHeight(String height) {
271     this.height = height;
272   } */
273 
274   /**
275    * A method binding EL expression,
276    * accepting FacesContext, UIComponent,
277    * and Object parameters, and returning void, that validates
278    * the component's local value.
279    */
280   @TagAttribute
281   @UIComponentTagAttribute(type = {},
282       expression = DynamicExpression.METHOD_BINDING,
283       methodSignature = { "javax.faces.context.FacesContext", "javax.faces.component.UIComponent", "java.lang.Object" })
284   public void setValidator(javax.el.MethodExpression validator) {
285     this.validator = validator;
286   }
287 
288   /**
289    * An expression that specifies the Converter for this component.
290    * If the value binding expression is a String,
291    * the String is used as an ID to look up a Converter.
292    * If the value binding expression is a Converter,
293    * uses that instance as the converter.
294    * The value can either be a static value (ID case only)
295    * or an EL expression.
296    */
297   @TagAttribute
298   @UIComponentTagAttribute(type = "javax.faces.convert.Converter",
299       expression = DynamicExpression.VALUE_BINDING)
300   public void setConverter(javax.el.ValueExpression converter) {
301     this.converter = converter;
302   }
303 
304   /**
305    * Flag indicating whether or not this component should be rendered
306    * (during Render Response Phase), or processed on any subsequent form submit.
307    */
308   @TagAttribute
309   @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.TRUE")
310   public void setRendered(javax.el.ValueExpression rendered) {
311     this.rendered = rendered;
312   }
313 
314   /**
315    * The value binding expression linking this
316    * component to a property in a backing bean.
317    */
318   @TagAttribute
319   @UIComponentTagAttribute(type = "javax.faces.component.UIComponent")
320   public void setBinding(javax.el.ValueExpression binding) {
321     this.binding = binding;
322   }
323 
324   /**
325    * Text value to display as tooltip.
326    */
327   @TagAttribute
328   @UIComponentTagAttribute()
329   public void setTip(javax.el.ValueExpression tip) {
330     this.tip = tip;
331   }
332 
333   /**
334    * The width for the label component. Default: 'fixed'.
335    * This value is used in the gridLayouts columns attribute.
336    * See gridLayout tag for valid values.
337    */
338   @TagAttribute
339   @UIComponentTagAttribute()
340   public void setLabelWidth(javax.el.ValueExpression labelWidth) {
341     this.labelWidth = labelWidth;
342   }
343 
344   /**
345    * Indicate markup of this component.
346    * Possible value is 'none'. But this can be overridden in the theme.
347    */
348   @TagAttribute
349   @UIComponentTagAttribute(defaultValue = "none", type = "java.lang.String[]")
350   public void setMarkup(javax.el.ValueExpression markup) {
351     this.markup = markup;
352   }
353 
354   @TagAttribute
355   @UIComponentTagAttribute(type = "java.lang.Integer")
356   public void setTabIndex(javax.el.ValueExpression tabIndex) {
357     this.tabIndex = tabIndex;
358   }
359 
360   /**
361    * Flag indicating this component should recieve the focus.
362    */
363   @TagAttribute
364   @UIComponentTagAttribute(type = "java.lang.Boolean")
365   public void setFocus(javax.el.ValueExpression focus) {
366     this.focus = focus;
367   }
368 
369   /**
370    * Range of items to render.
371    */
372   @TagAttribute
373   @UIComponentTagAttribute()
374   public void setRenderRange(javax.el.ValueExpression renderRange) {
375     this.renderRange = renderRange;
376   }
377 
378   /**
379    * An expression that specifies the validator message
380    */
381   @TagAttribute
382   @UIComponentTagAttribute()
383   public void setValidatorMessage(javax.el.ValueExpression validatorMessage) {
384     this.validatorMessage = validatorMessage;
385   }
386 
387   /**
388    * An expression that specifies the converter message
389    */
390   @TagAttribute
391   @UIComponentTagAttribute()
392   public void setConverterMessage(javax.el.ValueExpression converterMessage) {
393     this.converterMessage = converterMessage;
394   }
395 
396   /**
397    * An expression that specifies the required message
398    */
399   @TagAttribute
400   @UIComponentTagAttribute()
401   public void setRequiredMessage(javax.el.ValueExpression requiredMessage) {
402     this.requiredMessage = requiredMessage;
403   }
404   
405 }
406