KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELOptionsTag.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.OptionsTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Tag for creating multiple <select> options from a collection. The
27  * associated values displayed to the user may optionally be specified by a
28  * second collection, or will be the same as the values themselves. Each
29  * collection may be an array of objects, a Collection, an Enumeration,
30  * an Iterator, or a Map.
31  * <b>NOTE</b> - This tag requires a Java2 (JDK 1.2 or later) platform.
32  *<p>
33  * This class is a subclass of the class
34  * <code>org.apache.struts.taglib.html.OptionsTag</code> which provides most of
35  * the described functionality. This subclass allows all attribute values to
36  * be specified as expressions utilizing the JavaServer Pages Standard Library
37  * expression language.
38  *
39  * @version $Rev: 54933 $
40  */

41 public class ELOptionsTag extends OptionsTag {
42
43     /**
44      * Instance variable mapped to "collection" tag attribute.
45      * (Mapping set in associated BeanInfo class.)
46      */

47     private String JavaDoc collectionExpr;
48     /**
49      * Instance variable mapped to "filter" tag attribute.
50      * (Mapping set in associated BeanInfo class.)
51      */

52     private String JavaDoc filterExpr;
53     /**
54      * Instance variable mapped to "labelName" tag attribute.
55      * (Mapping set in associated BeanInfo class.)
56      */

57     private String JavaDoc labelNameExpr;
58     /**
59      * Instance variable mapped to "labelProperty" tag attribute.
60      * (Mapping set in associated BeanInfo class.)
61      */

62     private String JavaDoc labelPropertyExpr;
63     /**
64      * Instance variable mapped to "name" tag attribute.
65      * (Mapping set in associated BeanInfo class.)
66      */

67     private String JavaDoc nameExpr;
68     /**
69      * Instance variable mapped to "property" tag attribute.
70      * (Mapping set in associated BeanInfo class.)
71      */

72     private String JavaDoc propertyExpr;
73     /**
74      * Instance variable mapped to "style" tag attribute.
75      * (Mapping set in associated BeanInfo class.)
76      */

77     private String JavaDoc styleExpr;
78     /**
79      * Instance variable mapped to "styleClass" tag attribute.
80      * (Mapping set in associated BeanInfo class.)
81      */

82     private String JavaDoc styleClassExpr;
83
84     /**
85      * Getter method for "collection" tag attribute.
86      * (Mapping set in associated BeanInfo class.)
87      */

88     public String JavaDoc getCollectionExpr() { return (collectionExpr); }
89     /**
90      * Getter method for "filter" tag attribute.
91      * (Mapping set in associated BeanInfo class.)
92      */

93     public String JavaDoc getFilterExpr() { return (filterExpr); }
94     /**
95      * Getter method for "labelName" tag attribute.
96      * (Mapping set in associated BeanInfo class.)
97      */

98     public String JavaDoc getLabelNameExpr() { return (labelNameExpr); }
99     /**
100      * Getter method for "labelProperty" tag attribute.
101      * (Mapping set in associated BeanInfo class.)
102      */

103     public String JavaDoc getLabelPropertyExpr() { return (labelPropertyExpr); }
104     /**
105      * Getter method for "name" tag attribute.
106      * (Mapping set in associated BeanInfo class.)
107      */

108     public String JavaDoc getNameExpr() { return (nameExpr); }
109     /**
110      * Getter method for "property" tag attribute.
111      * (Mapping set in associated BeanInfo class.)
112      */

113     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
114     /**
115      * Getter method for "style" tag attribute.
116      * (Mapping set in associated BeanInfo class.)
117      */

118     public String JavaDoc getStyleExpr() { return (styleExpr); }
119     /**
120      * Getter method for "styleClass" tag attribute.
121      * (Mapping set in associated BeanInfo class.)
122      */

123     public String JavaDoc getStyleClassExpr() { return (styleClassExpr); }
124
125     /**
126      * Setter method for "collection" tag attribute.
127      * (Mapping set in associated BeanInfo class.)
128      */

129     public void setCollectionExpr(String JavaDoc collectionExpr) { this.collectionExpr = collectionExpr; }
130     /**
131      * Setter method for "filter" tag attribute.
132      * (Mapping set in associated BeanInfo class.)
133      */

134     public void setFilterExpr(String JavaDoc filterExpr) { this.filterExpr = filterExpr; }
135     /**
136      * Setter method for "labelName" tag attribute.
137      * (Mapping set in associated BeanInfo class.)
138      */

139     public void setLabelNameExpr(String JavaDoc labelNameExpr) { this.labelNameExpr = labelNameExpr; }
140     /**
141      * Setter method for "labelProperty" tag attribute.
142      * (Mapping set in associated BeanInfo class.)
143      */

144     public void setLabelPropertyExpr(String JavaDoc labelPropertyExpr) { this.labelPropertyExpr = labelPropertyExpr; }
145     /**
146      * Setter method for "name" tag attribute.
147      * (Mapping set in associated BeanInfo class.)
148      */

149     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
150     /**
151      * Setter method for "property" tag attribute.
152      * (Mapping set in associated BeanInfo class.)
153      */

154     public void setPropertyExpr(String JavaDoc propertyExpr) { this.propertyExpr = propertyExpr; }
155     /**
156      * Setter method for "style" tag attribute.
157      * (Mapping set in associated BeanInfo class.)
158      */

159     public void setStyleExpr(String JavaDoc styleExpr) { this.styleExpr = styleExpr; }
160     /**
161      * Setter method for "styleClass" tag attribute.
162      * (Mapping set in associated BeanInfo class.)
163      */

164     public void setStyleClassExpr(String JavaDoc styleClassExpr) { this.styleClassExpr = styleClassExpr; }
165
166     /**
167      * Resets attribute values for tag reuse.
168      */

169     public void release()
170     {
171         super.release();
172         setCollectionExpr(null);
173         setFilterExpr(null);
174         setLabelNameExpr(null);
175         setLabelPropertyExpr(null);
176         setNameExpr(null);
177         setPropertyExpr(null);
178         setStyleExpr(null);
179         setStyleClassExpr(null);
180     }
181
182     /**
183      * Process the start tag.
184      *
185      * @exception JspException if a JSP exception has occurred
186      */

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

198     private void evaluateExpressions() throws JspException JavaDoc {
199         String JavaDoc string = null;
200         Boolean JavaDoc bool = null;
201
202         if ((string = EvalHelper.evalString("collection", getCollectionExpr(),
203                                             this, pageContext)) != null)
204             setCollection(string);
205
206         if ((bool = EvalHelper.evalBoolean("filter", getFilterExpr(),
207                                            this, pageContext)) != null)
208             setFilter(bool.booleanValue());
209
210         if ((string = EvalHelper.evalString("labelName", getLabelNameExpr(),
211                                             this, pageContext)) != null)
212             setLabelName(string);
213
214         if ((string = EvalHelper.evalString("labelProperty", getLabelPropertyExpr(),
215                                             this, pageContext)) != null)
216             setLabelProperty(string);
217
218         if ((string = EvalHelper.evalString("name", getNameExpr(),
219                                             this, pageContext)) != null)
220             setName(string);
221
222         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
223                                             this, pageContext)) != null)
224             setProperty(string);
225
226         if ((string = EvalHelper.evalString("style", getStyleExpr(),
227                                             this, pageContext)) != null)
228             setStyle(string);
229
230         if ((string = EvalHelper.evalString("styleClass", getStyleClassExpr(),
231                                             this, pageContext)) != null)
232             setStyleClass(string);
233
234         // Note that in contrast to other elements which have "style" and
235
// "styleClass" attributes, this tag does not have a "styleId"
236
// attribute. This is because this produces the "id" attribute, which
237
// has to be unique document-wide, but this tag can generate more than
238
// one "option" element. Thus, the base tag, "Options" does not
239
// support this attribute.
240
}
241 }
242
Popular Tags