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