KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > logic > ELIterateTag


1 /*
2  * $Id: ELIterateTag.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.logic;
20
21 import org.apache.struts.taglib.logic.IterateTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Custom tag that iterates the elements of a collection, which can be
27  * either an attribute or the property of an attribute. The collection
28  * can be any of the following: an array of objects, an Enumeration,
29  * an Iterator, a Collection (which includes Lists, Sets and Vectors),
30  * or a Map (which includes Hashtables) whose elements will be iterated over.
31  *<p>
32  * This class is a subclass of the class
33  * <code>org.apache.struts.taglib.logic.IterateTag</code> which provides most of
34  * the described functionality. This subclass allows all attribute values to
35  * be specified as expressions utilizing the JavaServer Pages Standard Library
36  * expression language.
37  *
38  * @version $Rev: 54933 $
39  */

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

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

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

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

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

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

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

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

81     private String JavaDoc scopeExpr;
82     /**
83      * Instance variable mapped to "type" tag attribute.
84      * (Mapping set in associated BeanInfo class.)
85      */

86     private String JavaDoc typeExpr;
87
88     /**
89      * Getter method for "collection" tag attribute.
90      * (Mapping set in associated BeanInfo class.)
91      */

92     public String JavaDoc getCollectionExpr() { return (collectionExpr); }
93     /**
94      * Getter method for "id" tag attribute.
95      * (Mapping set in associated BeanInfo class.)
96      */

97     public String JavaDoc getIdExpr() { return (idExpr); }
98     /**
99      * Getter method for "indexId" tag attribute.
100      * (Mapping set in associated BeanInfo class.)
101      */

102     public String JavaDoc getIndexIdExpr() { return (indexIdExpr); }
103     /**
104      * Getter method for "length" tag attribute.
105      * (Mapping set in associated BeanInfo class.)
106      */

107     public String JavaDoc getLengthExpr() { return (lengthExpr); }
108     /**
109      * Getter method for "name" tag attribute.
110      * (Mapping set in associated BeanInfo class.)
111      */

112     public String JavaDoc getNameExpr() { return (nameExpr); }
113     /**
114      * Getter method for "offset" tag attribute.
115      * (Mapping set in associated BeanInfo class.)
116      */

117     public String JavaDoc getOffsetExpr() { return (offsetExpr); }
118     /**
119      * Getter method for "property" tag attribute.
120      * (Mapping set in associated BeanInfo class.)
121      */

122     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
123     /**
124      * Getter method for "scope" tag attribute.
125      * (Mapping set in associated BeanInfo class.)
126      */

127     public String JavaDoc getScopeExpr() { return (scopeExpr); }
128     /**
129      * Getter method for "type" tag attribute.
130      * (Mapping set in associated BeanInfo class.)
131      */

132     public String JavaDoc getTypeExpr() { return (typeExpr); }
133
134     /**
135      * Setter method for "collection" tag attribute.
136      * (Mapping set in associated BeanInfo class.)
137      */

138     public void setCollectionExpr(String JavaDoc collectionExpr) { this.collectionExpr = collectionExpr; }
139     /**
140      * Setter method for "id" tag attribute.
141      * (Mapping set in associated BeanInfo class.)
142      */

143     public void setIdExpr(String JavaDoc idExpr) { this.idExpr = idExpr; }
144     /**
145      * Setter method for "indexId" tag attribute.
146      * (Mapping set in associated BeanInfo class.)
147      */

148     public void setIndexIdExpr(String JavaDoc indexIdExpr) { this.indexIdExpr = indexIdExpr; }
149     /**
150      * Setter method for "length" tag attribute.
151      * (Mapping set in associated BeanInfo class.)
152      */

153     public void setLengthExpr(String JavaDoc lengthExpr) { this.lengthExpr = lengthExpr; }
154     /**
155      * Setter method for "name" tag attribute.
156      * (Mapping set in associated BeanInfo class.)
157      */

158     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
159     /**
160      * Setter method for "offset" tag attribute.
161      * (Mapping set in associated BeanInfo class.)
162      */

163     public void setOffsetExpr(String JavaDoc offsetExpr) { this.offsetExpr = offsetExpr; }
164     /**
165      * Setter method for "property" tag attribute.
166      * (Mapping set in associated BeanInfo class.)
167      */

168     public void setPropertyExpr(String JavaDoc propertyExpr) { this.propertyExpr = propertyExpr; }
169     /**
170      * Setter method for "scope" tag attribute.
171      * (Mapping set in associated BeanInfo class.)
172      */

173     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
174     /**
175      * Setter method for "type" tag attribute.
176      * (Mapping set in associated BeanInfo class.)
177      */

178     public void setTypeExpr(String JavaDoc typeExpr) { this.typeExpr = typeExpr; }
179
180     /**
181      * Releases state of custom tag so this instance can be reused.
182      */

183     public void release()
184     {
185         super.release();
186         setCollectionExpr(null);
187         setIdExpr(null);
188         setIndexIdExpr(null);
189         setLengthExpr(null);
190         setNameExpr(null);
191         setOffsetExpr(null);
192         setPropertyExpr(null);
193         setScopeExpr(null);
194         setTypeExpr(null);
195     }
196
197     /**
198      * Process the start tag.
199      *
200      * @exception JspException if a JSP exception has occurred
201      */

202     public int doStartTag() throws JspException JavaDoc {
203         evaluateExpressions();
204         return(super.doStartTag());
205     }
206
207     /**
208      * Processes all attribute values which use the JSTL expression evaluation
209      * engine to determine their values.
210      *
211      * @exception JspException if a JSP exception has occurred
212      */

213     private void evaluateExpressions() throws JspException JavaDoc {
214         String JavaDoc string = null;
215         Object JavaDoc object = null;
216
217         if ((object = EvalHelper.eval("collection", getCollectionExpr(),
218                                       this, pageContext)) != null)
219             setCollection(object);
220
221         if ((string = EvalHelper.evalString("id", getIdExpr(),
222                                             this, pageContext)) != null)
223             setId(string);
224
225         if ((string = EvalHelper.evalString("indexId", getIndexIdExpr(),
226                                             this, pageContext)) != null)
227             setIndexId(string);
228
229         if ((string = EvalHelper.evalString("length", getLengthExpr(),
230                                             this, pageContext)) != null)
231             setLength(string);
232
233         if ((string = EvalHelper.evalString("name", getNameExpr(),
234                                             this, pageContext)) != null)
235             setName(string);
236
237         if ((string = EvalHelper.evalString("offset", getOffsetExpr(),
238                                             this, pageContext)) != null)
239             setOffset(string);
240
241         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
242                                             this, pageContext)) != null)
243             setProperty(string);
244
245         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
246                                             this, pageContext)) != null)
247             setScope(string);
248
249         if ((string = EvalHelper.evalString("type", getTypeExpr(),
250                                             this, pageContext)) != null)
251             setType(string);
252     }
253 }
254
Popular Tags