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