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