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