View Javadoc

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