View Javadoc

1   package org.apache.myfaces.tobago.taglib.extension;
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.internal.taglib.SelectOneListboxTag;
23  import org.apache.myfaces.tobago.taglib.decl.HasBinding;
24  import org.apache.myfaces.tobago.taglib.decl.HasConverter;
25  import org.apache.myfaces.tobago.taglib.decl.HasConverterMessage;
26  import org.apache.myfaces.tobago.taglib.decl.HasId;
27  import org.apache.myfaces.tobago.taglib.decl.HasLabel;
28  import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
29  import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
30  import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
31  import org.apache.myfaces.tobago.taglib.decl.HasRequiredMessage;
32  import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
33  import org.apache.myfaces.tobago.taglib.decl.HasTip;
34  import org.apache.myfaces.tobago.taglib.decl.HasValidator;
35  import org.apache.myfaces.tobago.taglib.decl.HasValidatorMessage;
36  import org.apache.myfaces.tobago.taglib.decl.HasValue;
37  import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
38  import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
39  import org.apache.myfaces.tobago.taglib.decl.IsFocus;
40  import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
41  import org.apache.myfaces.tobago.taglib.decl.IsRendered;
42  import org.apache.myfaces.tobago.taglib.decl.IsRequired;
43  
44  import javax.servlet.jsp.JspException;
45  import javax.servlet.jsp.tagext.BodyTagSupport;
46  
47  /**
48   * Render a single selection option listbox.
49   */
50  @Tag(name = "selectOneListbox")
51  @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.internal.taglib.SelectOneListboxTag")
52  public class SelectOneListboxExtensionTag
53      extends BodyTagSupport implements HasId, HasValue, HasValueChangeListener, IsDisabled,
54      HasLabel, HasLabelWidth, IsReadonly, HasOnchange, IsRendered,
55      HasValidatorMessage, HasRequiredMessage, HasConverterMessage, HasMarkup,
56      HasBinding, IsFocus, HasTip, IsRequired, HasConverter, HasValidator, HasTabIndex {
57    private String required;
58    private String value;
59    private String valueChangeListener;
60    private String disabled;
61    private String readonly;
62    private String onchange;
63    private String label;
64    private String rendered;
65    private String binding;
66    private String tip;
67    private String converter;
68    private String validator;
69    private String labelWidth;
70    private String tabIndex;
71    private String focus;
72    private String validatorMessage;
73    private String converterMessage;
74    private String requiredMessage;
75    private String markup;
76  
77    private LabelExtensionTag labelTag;
78    private SelectOneListboxTag selectOneListboxTag;
79  
80    @Override
81    public int doStartTag() throws JspException {
82  
83      labelTag = new LabelExtensionTag();
84      labelTag.setPageContext(pageContext);
85      labelTag.setRows("*");
86      if (label != null) {
87        labelTag.setValue(label);
88      }
89      if (tip != null) {
90        labelTag.setTip(tip);
91      }
92      if (rendered != null) {
93        labelTag.setRendered(rendered);
94      }
95      if (labelWidth != null) {
96        labelTag.setColumns(labelWidth + ";*");
97      }
98      if (markup != null) {
99        labelTag.setMarkup(markup);
100     }
101     labelTag.setParent(getParent());
102     labelTag.doStartTag();
103 
104     selectOneListboxTag = new SelectOneListboxTag();
105     selectOneListboxTag.setPageContext(pageContext);
106     if (value != null) {
107       selectOneListboxTag.setValue(value);
108     }
109     if (valueChangeListener != null) {
110       selectOneListboxTag.setValueChangeListener(valueChangeListener);
111     }
112     if (binding != null) {
113       selectOneListboxTag.setBinding(binding);
114     }
115     if (onchange != null) {
116       selectOneListboxTag.setOnchange(onchange);
117     }
118     if (validator != null) {
119       selectOneListboxTag.setValidator(validator);
120     }
121     if (converter != null) {
122       selectOneListboxTag.setConverter(converter);
123     }
124     if (disabled != null) {
125       selectOneListboxTag.setDisabled(disabled);
126     }
127     /*if (inline != null) {
128       selectOneListboxTag.setInline(inline);
129     }*/
130     if (focus != null) {
131       selectOneListboxTag.setFocus(focus);
132     }
133     if (id != null) {
134       selectOneListboxTag.setId(id);
135     }
136     if (readonly != null) {
137       selectOneListboxTag.setReadonly(readonly);
138     }
139     if (required != null) {
140       selectOneListboxTag.setRequired(required);
141     }
142     if (tabIndex != null) {
143       selectOneListboxTag.setTabIndex(tabIndex);
144     }
145     if (validatorMessage != null) {
146       selectOneListboxTag.setValidatorMessage(validatorMessage);
147     }
148     if (converterMessage != null) {
149       selectOneListboxTag.setConverterMessage(converterMessage);
150     }
151     if (requiredMessage != null) {
152       selectOneListboxTag.setRequiredMessage(requiredMessage);
153     }
154     if (markup != null) {
155       selectOneListboxTag.setMarkup(markup);
156     }
157 
158     selectOneListboxTag.setParent(labelTag);
159     selectOneListboxTag.doStartTag();
160 
161     return super.doStartTag();
162   }
163 
164   @Override
165   public int doEndTag() throws JspException {
166     selectOneListboxTag.doEndTag();
167     labelTag.doEndTag();
168     return super.doEndTag();
169   }
170 
171   @Override
172   public void release() {
173     super.release();
174     binding = null;
175     onchange = null;
176     disabled = null;
177     labelWidth = null;
178     label = null;
179     readonly = null;
180     rendered = null;
181     converter = null;
182     validator = null;
183     required = null;
184     tip = null;
185     value = null;
186     valueChangeListener = null;
187     tabIndex = null;
188     selectOneListboxTag = null;
189     labelTag = null;
190     focus = null;
191     validatorMessage = null;
192     converterMessage = null;
193     requiredMessage = null;
194     markup = null;
195   }
196 
197   public void setRequired(String required) {
198     this.required = required;
199   }
200 
201   public void setValue(String value) {
202     this.value = value;
203   }
204 
205   public void setValueChangeListener(String valueChangeListener) {
206     this.valueChangeListener = valueChangeListener;
207   }
208 
209   public void setDisabled(String disabled) {
210     this.disabled = disabled;
211   }
212 
213   public void setReadonly(String readonly) {
214     this.readonly = readonly;
215   }
216 
217   public void setOnchange(String onchange) {
218     this.onchange = onchange;
219   }
220 
221   public void setLabel(String label) {
222     this.label = label;
223   }
224 
225   public void setValidator(String validator) {
226     this.validator = validator;
227   }
228 
229   public void setConverter(String converter) {
230     this.converter = converter;
231   }
232 
233   public void setRendered(String rendered) {
234     this.rendered = rendered;
235   }
236 
237   public void setBinding(String binding) {
238     this.binding = binding;
239   }
240 
241   public void setTip(String tip) {
242     this.tip = tip;
243   }
244 
245   public void setLabelWidth(String labelWidth) {
246     this.labelWidth = labelWidth;
247   }
248 
249   public void setTabIndex(String tabIndex) {
250     this.tabIndex = tabIndex;
251   }
252 
253   public void setFocus(String focus) {
254     this.focus = focus;
255   }
256 
257   public void setValidatorMessage(String validatorMessage) {
258     this.validatorMessage = validatorMessage;
259   }
260 
261   public void setConverterMessage(String converterMessage) {
262     this.converterMessage = converterMessage;
263   }
264 
265   public void setRequiredMessage(String requiredMessage) {
266     this.requiredMessage = requiredMessage;
267   }
268 
269   public void setMarkup(String markup) {
270     this.markup = markup;
271   }
272 }