View Javadoc

1   /*
2    * $Id: ELInsertTag.java 376781 2006-02-10 18:09:48Z 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.tiles;
19  
20  import org.apache.struts.tiles.taglib.InsertTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
24  
25  /***
26   * This is the tag handler for <tiles:insert>, which includes a
27   * template. The tag's body content consists of <tiles:put> tags, which
28   * are accessed by &lt;tiles:get&gt; in the template. <p> This class is a
29   * subclass of the class <code>org.apache.struts.taglib.tiles.InsertTag</code>
30   * which provides most of the described functionality.  This subclass allows
31   * all attribute values to be specified as expressions utilizing the
32   * JavaServer Pages Standard Library expression language.
33   *
34   * @version $Rev: 376781 $
35   */
36  public class ELInsertTag extends InsertTag {
37      /***
38       * Instance variable mapped to "template" tag attribute. (Mapping set in
39       * associated BeanInfo class.)
40       */
41      private String templateExpr;
42  
43      /***
44       * Instance variable mapped to "component" tag attribute. (Mapping set in
45       * associated BeanInfo class.)
46       */
47      private String componentExpr;
48  
49      /***
50       * Instance variable mapped to "page" tag attribute. (Mapping set in
51       * associated BeanInfo class.)
52       */
53      private String pageExpr;
54  
55      /***
56       * Instance variable mapped to "definition" tag attribute. (Mapping set in
57       * associated BeanInfo class.)
58       */
59      private String definitionExpr;
60  
61      /***
62       * Instance variable mapped to "attribute" tag attribute. (Mapping set in
63       * associated BeanInfo class.)
64       */
65      private String attributeExpr;
66  
67      /***
68       * Instance variable mapped to "name" tag attribute. (Mapping set in
69       * associated BeanInfo class.)
70       */
71      private String nameExpr;
72  
73      /***
74       * Instance variable mapped to "beanName" tag attribute. (Mapping set in
75       * associated BeanInfo class.)
76       */
77      private String beanNameExpr;
78  
79      /***
80       * Instance variable mapped to "beanProperty" tag attribute. (Mapping set
81       * in associated BeanInfo class.)
82       */
83      private String beanPropertyExpr;
84  
85      /***
86       * Instance variable mapped to "beanScope" tag attribute. (Mapping set in
87       * associated BeanInfo class.)
88       */
89      private String beanScopeExpr;
90  
91      /***
92       * Instance variable mapped to "flush" tag attribute. (Mapping set in
93       * associated BeanInfo class.)
94       */
95      private String flushExpr;
96  
97      /***
98       * (Mapping set in associated BeanInfo class.) Instance variable mapped to
99       * "ignore" tag attribute.
100      */
101     private String ignoreExpr;
102 
103     /***
104      * Instance variable mapped to "role" tag attribute. (Mapping set in
105      * associated BeanInfo class.)
106      */
107     private String roleExpr;
108 
109     /***
110      * Instance variable mapped to "controllerUrl" tag attribute. (Mapping set
111      * in associated BeanInfo class.)
112      */
113     private String controllerUrlExpr;
114 
115     /***
116      * Instance variable mapped to "controllerClass" tag attribute. (Mapping
117      * set in associated BeanInfo class.)
118      */
119     private String controllerClassExpr;
120 
121     /***
122      * Getter method for "template" tag attribute. (Mapping set in associated
123      * BeanInfo class.)
124      */
125     public String getTemplateExpr() {
126         return (templateExpr);
127     }
128 
129     /***
130      * Getter method for "component" tag attribute. (Mapping set in associated
131      * BeanInfo class.)
132      */
133     public String getComponentExpr() {
134         return (componentExpr);
135     }
136 
137     /***
138      * Getter method for "page" tag attribute. (Mapping set in associated
139      * BeanInfo class.)
140      */
141     public String getPageExpr() {
142         return (pageExpr);
143     }
144 
145     /***
146      * Getter method for "definition" tag attribute. (Mapping set in
147      * associated BeanInfo class.)
148      */
149     public String getDefinitionExpr() {
150         return (definitionExpr);
151     }
152 
153     /***
154      * Getter method for "attribute" tag attribute. (Mapping set in associated
155      * BeanInfo class.)
156      */
157     public String getAttributeExpr() {
158         return (attributeExpr);
159     }
160 
161     /***
162      * Getter method for "name" tag attribute. (Mapping set in associated
163      * BeanInfo class.)
164      */
165     public String getNameExpr() {
166         return (nameExpr);
167     }
168 
169     /***
170      * Getter method for "beanName" tag attribute. (Mapping set in associated
171      * BeanInfo class.)
172      */
173     public String getBeanNameExpr() {
174         return (beanNameExpr);
175     }
176 
177     /***
178      * Getter method for "beanProperty" tag attribute. (Mapping set in
179      * associated BeanInfo class.)
180      */
181     public String getBeanPropertyExpr() {
182         return (beanPropertyExpr);
183     }
184 
185     /***
186      * Getter method for "beanScope" tag attribute. (Mapping set in associated
187      * BeanInfo class.)
188      */
189     public String getBeanScopeExpr() {
190         return (beanScopeExpr);
191     }
192 
193     /***
194      * Getter method for "flush" tag attribute. (Mapping set in associated
195      * BeanInfo class.)
196      */
197     public String getFlushExpr() {
198         return (flushExpr);
199     }
200 
201     /***
202      * Getter method for "ignore" tag attribute. (Mapping set in associated
203      * BeanInfo class.)
204      */
205     public String getIgnoreExpr() {
206         return (ignoreExpr);
207     }
208 
209     /***
210      * Getter method for "role" tag attribute. (Mapping set in associated
211      * BeanInfo class.)
212      */
213     public String getRoleExpr() {
214         return (roleExpr);
215     }
216 
217     /***
218      * Getter method for "controllerUrl" tag attribute. (Mapping set in
219      * associated BeanInfo class.)
220      */
221     public String getControllerUrlExpr() {
222         return (controllerUrlExpr);
223     }
224 
225     /***
226      * Getter method for "controllerClass" tag attribute. (Mapping set in
227      * associated BeanInfo class.)
228      */
229     public String getControllerClassExpr() {
230         return (controllerClassExpr);
231     }
232 
233     /***
234      * Setter method for "template" tag attribute. (Mapping set in associated
235      * BeanInfo class.)
236      */
237     public void setTemplateExpr(String templateExpr) {
238         this.templateExpr = templateExpr;
239     }
240 
241     /***
242      * Setter method for "component" tag attribute. (Mapping set in associated
243      * BeanInfo class.)
244      */
245     public void setComponentExpr(String componentExpr) {
246         this.componentExpr = componentExpr;
247     }
248 
249     /***
250      * Setter method for "page" tag attribute. (Mapping set in associated
251      * BeanInfo class.)
252      */
253     public void setPageExpr(String pageExpr) {
254         this.pageExpr = pageExpr;
255     }
256 
257     /***
258      * Setter method for "definition" tag attribute. (Mapping set in
259      * associated BeanInfo class.)
260      */
261     public void setDefinitionExpr(String definitionExpr) {
262         this.definitionExpr = definitionExpr;
263     }
264 
265     /***
266      * Setter method for "attribute" tag attribute. (Mapping set in associated
267      * BeanInfo class.)
268      */
269     public void setAttributeExpr(String attributeExpr) {
270         this.attributeExpr = attributeExpr;
271     }
272 
273     /***
274      * Setter method for "name" tag attribute. (Mapping set in associated
275      * BeanInfo class.)
276      */
277     public void setNameExpr(String nameExpr) {
278         this.nameExpr = nameExpr;
279     }
280 
281     /***
282      * Setter method for "beanName" tag attribute. (Mapping set in associated
283      * BeanInfo class.)
284      */
285     public void setBeanNameExpr(String beanNameExpr) {
286         this.beanNameExpr = beanNameExpr;
287     }
288 
289     /***
290      * Setter method for "beanProperty" tag attribute. (Mapping set in
291      * associated BeanInfo class.)
292      */
293     public void setBeanPropertyExpr(String beanPropertyExpr) {
294         this.beanPropertyExpr = beanPropertyExpr;
295     }
296 
297     /***
298      * Setter method for "beanScope" tag attribute. (Mapping set in associated
299      * BeanInfo class.)
300      */
301     public void setBeanScopeExpr(String beanScopeExpr) {
302         this.beanScopeExpr = beanScopeExpr;
303     }
304 
305     /***
306      * Setter method for "flush" tag attribute. (Mapping set in associated
307      * BeanInfo class.)
308      */
309     public void setFlushExpr(String flushExpr) {
310         this.flushExpr = flushExpr;
311     }
312 
313     /***
314      * Setter method for "ignore" tag attribute. (Mapping set in associated
315      * BeanInfo class.)
316      */
317     public void setIgnoreExpr(String ignoreExpr) {
318         this.ignoreExpr = ignoreExpr;
319     }
320 
321     /***
322      * Setter method for "role" tag attribute. (Mapping set in associated
323      * BeanInfo class.)
324      */
325     public void setRoleExpr(String roleExpr) {
326         this.roleExpr = roleExpr;
327     }
328 
329     /***
330      * Setter method for "controllerUrl" tag attribute. (Mapping set in
331      * associated BeanInfo class.)
332      */
333     public void setControllerUrlExpr(String controllerUrlExpr) {
334         this.controllerUrlExpr = controllerUrlExpr;
335     }
336 
337     /***
338      * Setter method for "controllerClass" tag attribute. (Mapping set in
339      * associated BeanInfo class.)
340      */
341     public void setControllerClassExpr(String controllerClassExpr) {
342         this.controllerClassExpr = controllerClassExpr;
343     }
344 
345     /***
346      * Resets attribute values for tag reuse.
347      */
348     public void release() {
349         super.release();
350         setTemplateExpr(null);
351         setComponentExpr(null);
352         setPageExpr(null);
353         setDefinitionExpr(null);
354         setAttributeExpr(null);
355         setNameExpr(null);
356         setBeanNameExpr(null);
357         setBeanPropertyExpr(null);
358         setBeanScopeExpr(null);
359         setFlushExpr(null);
360         setIgnoreExpr(null);
361         setRoleExpr(null);
362         setControllerUrlExpr(null);
363         setControllerClassExpr(null);
364     }
365 
366     /***
367      * Process the start tag.
368      *
369      * @throws JspException if a JSP exception has occurred
370      */
371     public int doStartTag() throws JspException {
372         evaluateExpressions();
373 
374         return (super.doStartTag());
375     }
376 
377     /***
378      * Processes all attribute values which use the JSTL expression evaluation
379      * engine to determine their values.
380      *
381      * @throws JspException if a JSP exception has occurred
382      */
383     private void evaluateExpressions()
384         throws JspException {
385         String string = null;
386         Boolean bool = null;
387 
388         if ((string =
389                 EvalHelper.evalString("template", getTemplateExpr(), this,
390                     pageContext)) != null) {
391             setTemplate(string);
392         }
393 
394         if ((string =
395                 EvalHelper.evalString("component", getComponentExpr(), this,
396                     pageContext)) != null) {
397             setComponent(string);
398         }
399 
400         if ((string =
401                 EvalHelper.evalString("page", getPageExpr(), this, pageContext)) != null) {
402             setPage(string);
403         }
404 
405         if ((string =
406                 EvalHelper.evalString("definition", getDefinitionExpr(), this,
407                     pageContext)) != null) {
408             setDefinition(string);
409         }
410 
411         if ((string =
412                 EvalHelper.evalString("attribute", getAttributeExpr(), this,
413                     pageContext)) != null) {
414             setAttribute(string);
415         }
416 
417         if ((string =
418                 EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
419             setName(string);
420         }
421 
422         if ((string =
423                 EvalHelper.evalString("beanName", getBeanNameExpr(), this,
424                     pageContext)) != null) {
425             setBeanName(string);
426         }
427 
428         if ((string =
429                 EvalHelper.evalString("beanProperty", getBeanPropertyExpr(),
430                     this, pageContext)) != null) {
431             setBeanProperty(string);
432         }
433 
434         if ((string =
435                 EvalHelper.evalString("beanScope", getBeanScopeExpr(), this,
436                     pageContext)) != null) {
437             setBeanScope(string);
438         }
439 
440         if ((string =
441                 EvalHelper.evalString("flush", getFlushExpr(), this, pageContext)) != null) {
442             setFlush(string);
443         }
444 
445         if ((bool =
446                 EvalHelper.evalBoolean("ignore", getIgnoreExpr(), this,
447                     pageContext)) != null) {
448             setIgnore(bool.booleanValue());
449         }
450 
451         if ((string =
452                 EvalHelper.evalString("role", getRoleExpr(), this, pageContext)) != null) {
453             setRole(string);
454         }
455 
456         if ((string =
457                 EvalHelper.evalString("controllerUrl", getControllerUrlExpr(),
458                     this, pageContext)) != null) {
459             setControllerUrl(string);
460         }
461 
462         if ((string =
463                 EvalHelper.evalString("controllerClass",
464                     getControllerClassExpr(), this, pageContext)) != null) {
465             setControllerClass(string);
466         }
467     }
468 }