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