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