KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELRewriteTag.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.RewriteTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Generate a URL-encoded URI as a string.
27  *<p>
28  * This class is a subclass of the class
29  * <code>org.apache.struts.taglib.html.RewriteTag</code> which provides most of
30  * the described functionality. This subclass allows all attribute values to
31  * be specified as expressions utilizing the JavaServer Pages Standard Library
32  * expression language.
33  *
34  * @version $Rev: 54933 $
35  */

36 public class ELRewriteTag extends RewriteTag {
37
38     /**
39      * Instance variable mapped to "action" tag attribute.
40      * (Mapping set in associated BeanInfo class.)
41      */

42     private String JavaDoc actionExpr;
43     /**
44      * Instance variable mapped to "module" tag attribute.
45      * (Mapping set in associated BeanInfo class.)
46      */

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

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

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

62     private String JavaDoc hrefExpr;
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 "page" tag attribute.
70      * (Mapping set in associated BeanInfo class.)
71      */

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

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

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

87     private String JavaDoc paramPropertyExpr;
88     /**
89      * Instance variable mapped to "paramScope" tag attribute.
90      * (Mapping set in associated BeanInfo class.)
91      */

92     private String JavaDoc paramScopeExpr;
93     /**
94      * Instance variable mapped to "property" tag attribute.
95      * (Mapping set in associated BeanInfo class.)
96      */

97     private String JavaDoc propertyExpr;
98     /**
99      * Instance variable mapped to "scope" tag attribute.
100      * (Mapping set in associated BeanInfo class.)
101      */

102     private String JavaDoc scopeExpr;
103     /**
104      * Instance variable mapped to "transaction" tag attribute.
105      * (Mapping set in associated BeanInfo class.)
106      */

107     private String JavaDoc transactionExpr;
108     /**
109      * Instance variable mapped to "useLocalEncoding" tag attribute.
110      * (Mapping set in associated BeanInfo class.)
111      */

112     private String JavaDoc useLocalEncodingExpr;
113
114     /**
115      * Getter method for "action" tag attribute.
116      * (Mapping set in associated BeanInfo class.)
117      */

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

123     public String JavaDoc getModuleExpr() { return (moduleExpr); }
124     /**
125      * Getter method for "anchor" tag attribute.
126      * (Mapping set in associated BeanInfo class.)
127      */

128     public String JavaDoc getAnchorExpr() { return (anchorExpr); }
129     /**
130      * Getter method for "forward" tag attribute.
131      * (Mapping set in associated BeanInfo class.)
132      */

133     public String JavaDoc getForwardExpr() { return (forwardExpr); }
134     /**
135      * Getter method for "href" tag attribute.
136      * (Mapping set in associated BeanInfo class.)
137      */

138     public String JavaDoc getHrefExpr() { return (hrefExpr); }
139     /**
140      * Getter method for "name" tag attribute.
141      * (Mapping set in associated BeanInfo class.)
142      */

143     public String JavaDoc getNameExpr() { return (nameExpr); }
144     /**
145      * Getter method for "page" tag attribute.
146      * (Mapping set in associated BeanInfo class.)
147      */

148     public String JavaDoc getPageExpr() { return (pageExpr); }
149     /**
150      * Getter method for "paramId" tag attribute.
151      * (Mapping set in associated BeanInfo class.)
152      */

153     public String JavaDoc getParamIdExpr() { return (paramIdExpr); }
154     /**
155      * Getter method for "paramName" tag attribute.
156      * (Mapping set in associated BeanInfo class.)
157      */

158     public String JavaDoc getParamNameExpr() { return (paramNameExpr); }
159     /**
160      * Getter method for "paramProperty" tag attribute.
161      * (Mapping set in associated BeanInfo class.)
162      */

163     public String JavaDoc getParamPropertyExpr() { return (paramPropertyExpr); }
164     /**
165      * Getter method for "paramScope" tag attribute.
166      * (Mapping set in associated BeanInfo class.)
167      */

168     public String JavaDoc getParamScopeExpr() { return (paramScopeExpr); }
169     /**
170      * Getter method for "property" tag attribute.
171      * (Mapping set in associated BeanInfo class.)
172      */

173     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
174     /**
175      * Getter method for "scope" tag attribute.
176      * (Mapping set in associated BeanInfo class.)
177      */

178     public String JavaDoc getScopeExpr() { return (scopeExpr); }
179     /**
180      * Getter method for "transaction" tag attribute.
181      * (Mapping set in associated BeanInfo class.)
182      */

183     public String JavaDoc getTransactionExpr() { return (transactionExpr); }
184     /**
185      * Getter method for "useLocalEncoding" tag attribute.
186      * (Mapping set in associated BeanInfo class.)
187      */

188     public String JavaDoc getUseLocalEncodingExpr() { return (useLocalEncodingExpr); }
189
190     /**
191      * Setter method for "action" tag attribute.
192      * (Mapping set in associated BeanInfo class.)
193      */

194     public void setActionExpr(String JavaDoc actionExpr) { this.actionExpr = actionExpr; }
195     /**
196      * Setter method for "module" tag attribute.
197      * (Mapping set in associated BeanInfo class.)
198      */

199     public void setModuleExpr(String JavaDoc moduleExpr) { this.moduleExpr = moduleExpr; }
200     /**
201      * Setter method for "anchor" tag attribute.
202      * (Mapping set in associated BeanInfo class.)
203      */

204     public void setAnchorExpr(String JavaDoc anchorExpr) { this.anchorExpr = anchorExpr; }
205     /**
206      * Setter method for "forward" tag attribute.
207      * (Mapping set in associated BeanInfo class.)
208      */

209     public void setForwardExpr(String JavaDoc forwardExpr) { this.forwardExpr = forwardExpr; }
210     /**
211      * Setter method for "href" tag attribute.
212      * (Mapping set in associated BeanInfo class.)
213      */

214     public void setHrefExpr(String JavaDoc hrefExpr) { this.hrefExpr = hrefExpr; }
215     /**
216      * Setter method for "name" tag attribute.
217      * (Mapping set in associated BeanInfo class.)
218      */

219     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
220     /**
221      * Setter method for "page" tag attribute.
222      * (Mapping set in associated BeanInfo class.)
223      */

224     public void setPageExpr(String JavaDoc pageExpr) { this.pageExpr = pageExpr; }
225     /**
226      * Setter method for "paramId" tag attribute.
227      * (Mapping set in associated BeanInfo class.)
228      */

229     public void setParamIdExpr(String JavaDoc paramIdExpr) { this.paramIdExpr = paramIdExpr; }
230     /**
231      * Setter method for "paramName" tag attribute.
232      * (Mapping set in associated BeanInfo class.)
233      */

234     public void setParamNameExpr(String JavaDoc paramNameExpr) { this.paramNameExpr = paramNameExpr; }
235     /**
236      * Setter method for "paramProperty" tag attribute.
237      * (Mapping set in associated BeanInfo class.)
238      */

239     public void setParamPropertyExpr(String JavaDoc paramPropertyExpr) { this.paramPropertyExpr = paramPropertyExpr; }
240     /**
241      * Setter method for "paramScope" tag attribute.
242      * (Mapping set in associated BeanInfo class.)
243      */

244     public void setParamScopeExpr(String JavaDoc paramScopeExpr) { this.paramScopeExpr = paramScopeExpr; }
245     /**
246      * Setter method for "property" tag attribute.
247      * (Mapping set in associated BeanInfo class.)
248      */

249     public void setPropertyExpr(String JavaDoc propertyExpr) { this.propertyExpr = propertyExpr; }
250     /**
251      * Setter method for "scope" tag attribute.
252      * (Mapping set in associated BeanInfo class.)
253      */

254     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
255     /**
256      * Setter method for "transaction" tag attribute.
257      * (Mapping set in associated BeanInfo class.)
258      */

259     public void setTransactionExpr(String JavaDoc transactionExpr) { this.transactionExpr = transactionExpr; }
260     /**
261      * Setter method for "useLocalEncoding" tag attribute.
262      * (Mapping set in associated BeanInfo class.)
263      */

264     public void setUseLocalEncodingExpr(String JavaDoc useLocalEncodingExpr) { this.useLocalEncodingExpr = useLocalEncodingExpr; }
265
266     /**
267      * Resets attribute values for tag reuse.
268      */

269     public void release()
270     {
271         super.release();
272         setActionExpr(null);
273         setModuleExpr(null);
274         setAnchorExpr(null);
275         setForwardExpr(null);
276         setHrefExpr(null);
277         setNameExpr(null);
278         setPageExpr(null);
279         setParamIdExpr(null);
280         setParamNameExpr(null);
281         setParamPropertyExpr(null);
282         setParamScopeExpr(null);
283         setPropertyExpr(null);
284         setScopeExpr(null);
285         setTransactionExpr(null);
286         setUseLocalEncodingExpr(null);
287     }
288
289     /**
290      * Process the start tag.
291      *
292      * @exception JspException if a JSP exception has occurred
293      */

294     public int doStartTag() throws JspException JavaDoc {
295         evaluateExpressions();
296         return(super.doStartTag());
297     }
298
299     /**
300      * Processes all attribute values which use the JSTL expression evaluation
301      * engine to determine their values.
302      *
303      * @exception JspException if a JSP exception has occurred
304      */

305     private void evaluateExpressions() throws JspException JavaDoc {
306         String JavaDoc string = null;
307         Boolean JavaDoc bool = null;
308
309         if ((string = EvalHelper.evalString("action", getActionExpr(),
310                                             this, pageContext)) != null)
311             setAction(string);
312
313         if ((string = EvalHelper.evalString("module", getModuleExpr(),
314                                             this, pageContext)) != null)
315             setModule(string);
316
317         if ((string = EvalHelper.evalString("anchor", getAnchorExpr(),
318                                             this, pageContext)) != null)
319             setAnchor(string);
320
321         if ((string = EvalHelper.evalString("forward", getForwardExpr(),
322                                             this, pageContext)) != null)
323             setForward(string);
324
325         if ((string = EvalHelper.evalString("href", getHrefExpr(),
326                                             this, pageContext)) != null)
327             setHref(string);
328
329         if ((string = EvalHelper.evalString("name", getNameExpr(),
330                                             this, pageContext)) != null)
331             setName(string);
332
333         if ((string = EvalHelper.evalString("page", getPageExpr(),
334                                             this, pageContext)) != null)
335             setPage(string);
336
337         if ((string = EvalHelper.evalString("paramId", getParamIdExpr(),
338                                             this, pageContext)) != null)
339             setParamId(string);
340
341         if ((string = EvalHelper.evalString("paramName", getParamNameExpr(),
342                                             this, pageContext)) != null)
343             setParamName(string);
344
345         if ((string = EvalHelper.evalString("paramProperty", getParamPropertyExpr(),
346                                             this, pageContext)) != null)
347             setParamProperty(string);
348
349         if ((string = EvalHelper.evalString("paramScope", getParamScopeExpr(),
350                                             this, pageContext)) != null)
351             setParamScope(string);
352
353         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
354                                             this, pageContext)) != null)
355             setProperty(string);
356
357         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
358                                             this, pageContext)) != null)
359             setScope(string);
360
361         if ((bool = EvalHelper.evalBoolean("transaction", getTransactionExpr(),
362                                            this, pageContext)) != null)
363             setTransaction(bool.booleanValue());
364
365         if ((bool = EvalHelper.evalBoolean("useLocalEncoding", getUseLocalEncodingExpr(),
366                                            this, pageContext)) != null)
367             setUseLocalEncoding(bool.booleanValue());
368     }
369 }
370
Popular Tags