KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > html > ELOptionTag


1 /*
2  * $Id: ELOptionTag.java 54933 2004-10-16 17:04:52Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.strutsel.taglib.html;
20
21 import org.apache.struts.taglib.html.OptionTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Tag for select options. The body of this tag is presented to the user
27  * in the option list, while the value attribute is the value returned to
28  * the server if this option is selected.
29  *<p>
30  * This class is a subclass of the class
31  * <code>org.apache.struts.taglib.html.OptionTag</code> which provides most of
32  * the described functionality. This subclass allows all attribute values to
33  * be specified as expressions utilizing the JavaServer Pages Standard Library
34  * expression language.
35  *
36  * @version $Rev: 54933 $
37  */

38 public class ELOptionTag extends OptionTag {
39
40     /**
41      * Instance variable mapped to "bundle" tag attribute.
42      * (Mapping set in associated BeanInfo class.)
43      */

44     private String JavaDoc bundleExpr;
45     /**
46      * Instance variable mapped to "disabled" tag attribute.
47      * (Mapping set in associated BeanInfo class.)
48      */

49     private String JavaDoc disabledExpr;
50     /**
51      * Instance variable mapped to "key" tag attribute.
52      * (Mapping set in associated BeanInfo class.)
53      */

54     private String JavaDoc keyExpr;
55     /**
56      * Instance variable mapped to "locale" tag attribute.
57      * (Mapping set in associated BeanInfo class.)
58      */

59     private String JavaDoc localeExpr;
60     /**
61      * Instance variable mapped to "style" tag attribute.
62      * (Mapping set in associated BeanInfo class.)
63      */

64     private String JavaDoc styleExpr;
65     /**
66      * Instance variable mapped to "styleClass" tag attribute.
67      * (Mapping set in associated BeanInfo class.)
68      */

69     private String JavaDoc styleClassExpr;
70     /**
71      * Instance variable mapped to "styleId" tag attribute.
72      * (Mapping set in associated BeanInfo class.)
73      */

74     private String JavaDoc styleIdExpr;
75     /**
76      * Instance variable mapped to "value" tag attribute.
77      * (Mapping set in associated BeanInfo class.)
78      */

79     private String JavaDoc valueExpr;
80
81     /**
82      * Getter method for "bundle" tag attribute.
83      * (Mapping set in associated BeanInfo class.)
84      */

85     public String JavaDoc getBundleExpr() { return (bundleExpr); }
86     /**
87      * Getter method for "disabled" tag attribute.
88      * (Mapping set in associated BeanInfo class.)
89      */

90     public String JavaDoc getDisabledExpr() { return (disabledExpr); }
91     /**
92      * Getter method for "key" tag attribute.
93      * (Mapping set in associated BeanInfo class.)
94      */

95     public String JavaDoc getKeyExpr() { return (keyExpr); }
96     /**
97      * Getter method for "locale" tag attribute.
98      * (Mapping set in associated BeanInfo class.)
99      */

100     public String JavaDoc getLocaleExpr() { return (localeExpr); }
101     /**
102      * Getter method for "style" tag attribute.
103      * (Mapping set in associated BeanInfo class.)
104      */

105     public String JavaDoc getStyleExpr() { return (styleExpr); }
106     /**
107      * Getter method for "styleClass" tag attribute.
108      * (Mapping set in associated BeanInfo class.)
109      */

110     public String JavaDoc getStyleClassExpr() { return (styleClassExpr); }
111     /**
112      * Getter method for "styleId" tag attribute.
113      * (Mapping set in associated BeanInfo class.)
114      */

115     public String JavaDoc getStyleIdExpr() { return (styleIdExpr); }
116     /**
117      * Getter method for "value" tag attribute.
118      * (Mapping set in associated BeanInfo class.)
119      */

120     public String JavaDoc getValueExpr() { return (valueExpr); }
121
122     /**
123      * Setter method for "bundle" tag attribute.
124      * (Mapping set in associated BeanInfo class.)
125      */

126     public void setBundleExpr(String JavaDoc bundleExpr) { this.bundleExpr = bundleExpr; }
127     /**
128      * Setter method for "disabled" tag attribute.
129      * (Mapping set in associated BeanInfo class.)
130      */

131     public void setDisabledExpr(String JavaDoc disabledExpr) { this.disabledExpr = disabledExpr; }
132     /**
133      * Setter method for "key" tag attribute.
134      * (Mapping set in associated BeanInfo class.)
135      */

136     public void setKeyExpr(String JavaDoc keyExpr) { this.keyExpr = keyExpr; }
137     /**
138      * Setter method for "locale" tag attribute.
139      * (Mapping set in associated BeanInfo class.)
140      */

141     public void setLocaleExpr(String JavaDoc localeExpr) { this.localeExpr = localeExpr; }
142     /**
143      * Setter method for "style" tag attribute.
144      * (Mapping set in associated BeanInfo class.)
145      */

146     public void setStyleExpr(String JavaDoc styleExpr) { this.styleExpr = styleExpr; }
147     /**
148      * Setter method for "styleClass" tag attribute.
149      * (Mapping set in associated BeanInfo class.)
150      */

151     public void setStyleClassExpr(String JavaDoc styleClassExpr) { this.styleClassExpr = styleClassExpr; }
152     /**
153      * Setter method for "styleId" tag attribute.
154      * (Mapping set in associated BeanInfo class.)
155      */

156     public void setStyleIdExpr(String JavaDoc styleIdExpr) { this.styleIdExpr = styleIdExpr; }
157     /**
158      * Setter method for "value" tag attribute.
159      * (Mapping set in associated BeanInfo class.)
160      */

161     public void setValueExpr(String JavaDoc valueExpr) { this.valueExpr = valueExpr; }
162
163     /**
164      * Resets attribute values for tag reuse.
165      */

166     public void release()
167     {
168         super.release();
169         setBundleExpr(null);
170         setDisabledExpr(null);
171         setKeyExpr(null);
172         setLocaleExpr(null);
173         setStyleExpr(null);
174         setStyleClassExpr(null);
175         setStyleIdExpr(null);
176         setValueExpr(null);
177     }
178
179     /**
180      * Process the start tag.
181      *
182      * @exception JspException if a JSP exception has occurred
183      */

184     public int doStartTag() throws JspException JavaDoc {
185         evaluateExpressions();
186         return(super.doStartTag());
187     }
188
189     /**
190      * Processes all attribute values which use the JSTL expression evaluation
191      * engine to determine their values.
192      *
193      * @exception JspException if a JSP exception has occurred
194      */

195     private void evaluateExpressions() throws JspException JavaDoc {
196         String JavaDoc string = null;
197         Boolean JavaDoc bool = null;
198
199         if ((string = EvalHelper.evalString("bundle", getBundleExpr(),
200                                             this, pageContext)) != null)
201             setBundle(string);
202
203         if ((bool = EvalHelper.evalBoolean("disabled", getDisabledExpr(),
204                                            this, pageContext)) != null)
205             setDisabled(bool.booleanValue());
206
207         if ((string = EvalHelper.evalString("key", getKeyExpr(),
208                                             this, pageContext)) != null)
209             setKey(string);
210
211         if ((string = EvalHelper.evalString("locale", getLocaleExpr(),
212                                             this, pageContext)) != null)
213             setLocale(string);
214
215         if ((string = EvalHelper.evalString("style", getStyleExpr(),
216                                             this, pageContext)) != null)
217             setStyle(string);
218
219         if ((string = EvalHelper.evalString("styleClass", getStyleClassExpr(),
220                                             this, pageContext)) != null)
221             setStyleClass(string);
222
223         if ((string = EvalHelper.evalString("styleId", getStyleIdExpr(),
224                                             this, pageContext)) != null)
225             setStyleId(string);
226
227         if ((string = EvalHelper.evalString("value", getValueExpr(),
228                                             this, pageContext)) != null)
229             setValue(string);
230     }
231 }
232
Popular Tags