View Javadoc

1   /*
2    * $Id: ELRedirectTag.java 376780 2006-02-10 18:09:22Z husted $
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  package org.apache.strutsel.taglib.logic;
19  
20  import org.apache.struts.taglib.logic.RedirectTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
24  
25  /***
26   * Generate a URL-encoded redirect to the specified URI. <p> This class is a
27   * subclass of the class <code>org.apache.struts.taglib.logic.RedirectTag</code>
28   * which provides most of the described functionality.  This subclass allows
29   * all attribute values to be specified as expressions utilizing the
30   * JavaServer Pages Standard Library expression language.
31   *
32   * @version $Rev: 376780 $
33   */
34  public class ELRedirectTag extends RedirectTag {
35      /***
36       * Instance variable mapped to "action" tag attribute. (Mapping set in
37       * associated BeanInfo class.)
38       */
39      private String actionExpr;
40  
41      /***
42       * Instance variable mapped to "anchor" tag attribute. (Mapping set in
43       * associated BeanInfo class.)
44       */
45      private String anchorExpr;
46  
47      /***
48       * Instance variable mapped to "forward" tag attribute. (Mapping set in
49       * associated BeanInfo class.)
50       */
51      private String forwardExpr;
52  
53      /***
54       * Instance variable mapped to "href" tag attribute. (Mapping set in
55       * associated BeanInfo class.)
56       */
57      private String hrefExpr;
58  
59      /***
60       * Instance variable mapped to "name" tag attribute. (Mapping set in
61       * associated BeanInfo class.)
62       */
63      private String nameExpr;
64  
65      /***
66       * Instance variable mapped to "page" tag attribute. (Mapping set in
67       * associated BeanInfo class.)
68       */
69      private String pageExpr;
70  
71      /***
72       * Instance variable mapped to "paramId" tag attribute. (Mapping set in
73       * associated BeanInfo class.)
74       */
75      private String paramIdExpr;
76  
77      /***
78       * Instance variable mapped to "paramName" tag attribute. (Mapping set in
79       * associated BeanInfo class.)
80       */
81      private String paramNameExpr;
82  
83      /***
84       * Instance variable mapped to "paramProperty" tag attribute. (Mapping set
85       * in associated BeanInfo class.)
86       */
87      private String paramPropertyExpr;
88  
89      /***
90       * Instance variable mapped to "paramScope" tag attribute. (Mapping set in
91       * associated BeanInfo class.)
92       */
93      private String paramScopeExpr;
94  
95      /***
96       * Instance variable mapped to "property" tag attribute. (Mapping set in
97       * associated BeanInfo class.)
98       */
99      private String propertyExpr;
100 
101     /***
102      * Instance variable mapped to "scope" tag attribute. (Mapping set in
103      * associated BeanInfo class.)
104      */
105     private String scopeExpr;
106 
107     /***
108      * Instance variable mapped to "transaction" tag attribute. (Mapping set
109      * in associated BeanInfo class.)
110      */
111     private String transactionExpr;
112 
113     /***
114      * Instance variable mapped to "useLocalEncoding" tag attribute. (Mapping
115      * set in associated BeanInfo class.)
116      */
117     private String useLocalEncodingExpr;
118 
119     /***
120      * Getter method for "action" tag attribute. (Mapping set in associated
121      * BeanInfo class.)
122      */
123     public String getActionExpr() {
124         return (actionExpr);
125     }
126 
127     /***
128      * Getter method for "anchor" tag attribute. (Mapping set in associated
129      * BeanInfo class.)
130      */
131     public String getAnchorExpr() {
132         return (anchorExpr);
133     }
134 
135     /***
136      * Getter method for "forward" tag attribute. (Mapping set in associated
137      * BeanInfo class.)
138      */
139     public String getForwardExpr() {
140         return (forwardExpr);
141     }
142 
143     /***
144      * Getter method for "href" tag attribute. (Mapping set in associated
145      * BeanInfo class.)
146      */
147     public String getHrefExpr() {
148         return (hrefExpr);
149     }
150 
151     /***
152      * Getter method for "name" tag attribute. (Mapping set in associated
153      * BeanInfo class.)
154      */
155     public String getNameExpr() {
156         return (nameExpr);
157     }
158 
159     /***
160      * Getter method for "page" tag attribute. (Mapping set in associated
161      * BeanInfo class.)
162      */
163     public String getPageExpr() {
164         return (pageExpr);
165     }
166 
167     /***
168      * Getter method for "paramId" tag attribute. (Mapping set in associated
169      * BeanInfo class.)
170      */
171     public String getParamIdExpr() {
172         return (paramIdExpr);
173     }
174 
175     /***
176      * Getter method for "paramName" tag attribute. (Mapping set in associated
177      * BeanInfo class.)
178      */
179     public String getParamNameExpr() {
180         return (paramNameExpr);
181     }
182 
183     /***
184      * Getter method for "paramProperty" tag attribute. (Mapping set in
185      * associated BeanInfo class.)
186      */
187     public String getParamPropertyExpr() {
188         return (paramPropertyExpr);
189     }
190 
191     /***
192      * Getter method for "paramScope" tag attribute. (Mapping set in
193      * associated BeanInfo class.)
194      */
195     public String getParamScopeExpr() {
196         return (paramScopeExpr);
197     }
198 
199     /***
200      * Getter method for "property" tag attribute. (Mapping set in associated
201      * BeanInfo class.)
202      */
203     public String getPropertyExpr() {
204         return (propertyExpr);
205     }
206 
207     /***
208      * Getter method for "scope" tag attribute. (Mapping set in associated
209      * BeanInfo class.)
210      */
211     public String getScopeExpr() {
212         return (scopeExpr);
213     }
214 
215     /***
216      * Getter method for "transaction" tag attribute. (Mapping set in
217      * associated BeanInfo class.)
218      */
219     public String getTransactionExpr() {
220         return (transactionExpr);
221     }
222 
223     /***
224      * Getter method for "useLocalEncoding" tag attribute. (Mapping set in
225      * associated BeanInfo class.)
226      */
227     public String getUseLocalEncodingExpr() {
228         return (useLocalEncodingExpr);
229     }
230 
231     /***
232      * Setter method for "action" tag attribute. (Mapping set in associated
233      * BeanInfo class.)
234      */
235     public void setActionExpr(String actionExpr) {
236         this.actionExpr = actionExpr;
237     }
238 
239     /***
240      * Setter method for "anchor" tag attribute. (Mapping set in associated
241      * BeanInfo class.)
242      */
243     public void setAnchorExpr(String anchorExpr) {
244         this.anchorExpr = anchorExpr;
245     }
246 
247     /***
248      * Setter method for "forward" tag attribute. (Mapping set in associated
249      * BeanInfo class.)
250      */
251     public void setForwardExpr(String forwardExpr) {
252         this.forwardExpr = forwardExpr;
253     }
254 
255     /***
256      * Setter method for "href" tag attribute. (Mapping set in associated
257      * BeanInfo class.)
258      */
259     public void setHrefExpr(String hrefExpr) {
260         this.hrefExpr = hrefExpr;
261     }
262 
263     /***
264      * Setter method for "name" tag attribute. (Mapping set in associated
265      * BeanInfo class.)
266      */
267     public void setNameExpr(String nameExpr) {
268         this.nameExpr = nameExpr;
269     }
270 
271     /***
272      * Setter method for "page" tag attribute. (Mapping set in associated
273      * BeanInfo class.)
274      */
275     public void setPageExpr(String pageExpr) {
276         this.pageExpr = pageExpr;
277     }
278 
279     /***
280      * Setter method for "paramId" tag attribute. (Mapping set in associated
281      * BeanInfo class.)
282      */
283     public void setParamIdExpr(String paramIdExpr) {
284         this.paramIdExpr = paramIdExpr;
285     }
286 
287     /***
288      * Setter method for "paramName" tag attribute. (Mapping set in associated
289      * BeanInfo class.)
290      */
291     public void setParamNameExpr(String paramNameExpr) {
292         this.paramNameExpr = paramNameExpr;
293     }
294 
295     /***
296      * Setter method for "paramProperty" tag attribute. (Mapping set in
297      * associated BeanInfo class.)
298      */
299     public void setParamPropertyExpr(String paramPropertyExpr) {
300         this.paramPropertyExpr = paramPropertyExpr;
301     }
302 
303     /***
304      * Setter method for "paramScope" tag attribute. (Mapping set in
305      * associated BeanInfo class.)
306      */
307     public void setParamScopeExpr(String paramScopeExpr) {
308         this.paramScopeExpr = paramScopeExpr;
309     }
310 
311     /***
312      * Setter method for "property" tag attribute. (Mapping set in associated
313      * BeanInfo class.)
314      */
315     public void setPropertyExpr(String propertyExpr) {
316         this.propertyExpr = propertyExpr;
317     }
318 
319     /***
320      * Setter method for "scope" tag attribute. (Mapping set in associated
321      * BeanInfo class.)
322      */
323     public void setScopeExpr(String scopeExpr) {
324         this.scopeExpr = scopeExpr;
325     }
326 
327     /***
328      * Setter method for "transaction" tag attribute. (Mapping set in
329      * associated BeanInfo class.)
330      */
331     public void setTransactionExpr(String transactionExpr) {
332         this.transactionExpr = transactionExpr;
333     }
334 
335     /***
336      * Setter method for "useLocalEncoding" tag attribute. (Mapping set in
337      * associated BeanInfo class.)
338      */
339     public void setUseLocalEncodingExpr(String useLocalEncodingExpr) {
340         this.useLocalEncodingExpr = useLocalEncodingExpr;
341     }
342 
343     /***
344      * Resets attribute values for tag reuse.
345      */
346     public void release() {
347         super.release();
348         setActionExpr(null);
349         setAnchorExpr(null);
350         setForwardExpr(null);
351         setHrefExpr(null);
352         setNameExpr(null);
353         setPageExpr(null);
354         setParamIdExpr(null);
355         setParamNameExpr(null);
356         setParamPropertyExpr(null);
357         setParamScopeExpr(null);
358         setPropertyExpr(null);
359         setScopeExpr(null);
360         setTransactionExpr(null);
361         setUseLocalEncodingExpr(null);
362     }
363 
364     /***
365      * Process the start tag.
366      *
367      * @throws JspException if a JSP exception has occurred
368      */
369     public int doStartTag() throws JspException {
370         evaluateExpressions();
371 
372         return (super.doStartTag());
373     }
374 
375     /***
376      * Processes all attribute values which use the JSTL expression evaluation
377      * engine to determine their values.
378      *
379      * @throws JspException if a JSP exception has occurred
380      */
381     private void evaluateExpressions()
382         throws JspException {
383         String string = null;
384         Boolean bool = null;
385 
386         if ((string =
387                 EvalHelper.evalString("action", getActionExpr(), this,
388                     pageContext)) != null) {
389             setAction(string);
390         }
391 
392         if ((string =
393                 EvalHelper.evalString("anchor", getAnchorExpr(), this,
394                     pageContext)) != null) {
395             setAnchor(string);
396         }
397 
398         if ((string =
399                 EvalHelper.evalString("forward", getForwardExpr(), this,
400                     pageContext)) != null) {
401             setForward(string);
402         }
403 
404         if ((string =
405                 EvalHelper.evalString("href", getHrefExpr(), this, pageContext)) != null) {
406             setHref(string);
407         }
408 
409         if ((string =
410                 EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
411             setName(string);
412         }
413 
414         if ((string =
415                 EvalHelper.evalString("page", getPageExpr(), this, pageContext)) != null) {
416             setPage(string);
417         }
418 
419         if ((string =
420                 EvalHelper.evalString("paramId", getParamIdExpr(), this,
421                     pageContext)) != null) {
422             setParamId(string);
423         }
424 
425         if ((string =
426                 EvalHelper.evalString("paramName", getParamNameExpr(), this,
427                     pageContext)) != null) {
428             setParamName(string);
429         }
430 
431         if ((string =
432                 EvalHelper.evalString("paramProperty", getParamPropertyExpr(),
433                     this, pageContext)) != null) {
434             setParamProperty(string);
435         }
436 
437         if ((string =
438                 EvalHelper.evalString("paramScope", getParamScopeExpr(), this,
439                     pageContext)) != null) {
440             setParamScope(string);
441         }
442 
443         if ((string =
444                 EvalHelper.evalString("property", getPropertyExpr(), this,
445                     pageContext)) != null) {
446             setProperty(string);
447         }
448 
449         if ((string =
450                 EvalHelper.evalString("scope", getScopeExpr(), this, pageContext)) != null) {
451             setScope(string);
452         }
453 
454         if ((bool =
455                 EvalHelper.evalBoolean("transaction", getTransactionExpr(),
456                     this, pageContext)) != null) {
457             setTransaction(bool.booleanValue());
458         }
459 
460         if ((bool =
461                 EvalHelper.evalBoolean("useLocalEncoding",
462                     getUseLocalEncodingExpr(), this, pageContext)) != null) {
463             setUseLocalEncoding(bool.booleanValue());
464         }
465     }
466 }