KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > tiles > ELInsertTag


1 /*
2  * $Id: ELInsertTag.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.tiles;
20
21 import org.apache.struts.taglib.tiles.InsertTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * This is the tag handler for <tiles:insert>, which includes
27  * a template. The tag's body content consists of <tiles:put>
28  * tags, which are accessed by <tiles:get> in the template.
29  *<p>
30  * This class is a subclass of the class
31  * <code>org.apache.struts.taglib.tiles.InsertTag</code> which provides most of
32  * the described functionality. This subclass allows all attribute values to
33  * be specified as expressions utilizing the JavaServer Pages Standard Library
34  * expression language.
35  *
36  * @version $Rev: 54933 $
37  */

38 public class ELInsertTag extends InsertTag {
39
40     /**
41      * Instance variable mapped to "template" tag attribute.
42      * (Mapping set in associated BeanInfo class.)
43      */

44     private String JavaDoc templateExpr;
45     /**
46      * Instance variable mapped to "component" tag attribute.
47      * (Mapping set in associated BeanInfo class.)
48      */

49     private String JavaDoc componentExpr;
50     /**
51      * Instance variable mapped to "page" tag attribute.
52      * (Mapping set in associated BeanInfo class.)
53      */

54     private String JavaDoc pageExpr;
55     /**
56      * Instance variable mapped to "definition" tag attribute.
57      * (Mapping set in associated BeanInfo class.)
58      */

59     private String JavaDoc definitionExpr;
60     /**
61      * Instance variable mapped to "attribute" tag attribute.
62      * (Mapping set in associated BeanInfo class.)
63      */

64     private String JavaDoc attributeExpr;
65     /**
66      * Instance variable mapped to "name" tag attribute.
67      * (Mapping set in associated BeanInfo class.)
68      */

69     private String JavaDoc nameExpr;
70     /**
71      * Instance variable mapped to "beanName" tag attribute.
72      * (Mapping set in associated BeanInfo class.)
73      */

74     private String JavaDoc beanNameExpr;
75     /**
76      * Instance variable mapped to "beanProperty" tag attribute.
77      * (Mapping set in associated BeanInfo class.)
78      */

79     private String JavaDoc beanPropertyExpr;
80     /**
81      * Instance variable mapped to "beanScope" tag attribute.
82      * (Mapping set in associated BeanInfo class.)
83      */

84     private String JavaDoc beanScopeExpr;
85     /**
86      * Instance variable mapped to "flush" tag attribute.
87      * (Mapping set in associated BeanInfo class.)
88      */

89     private String JavaDoc flushExpr;
90     /**
91      * (Mapping set in associated BeanInfo class.)
92      * Instance variable mapped to "ignore" tag attribute.
93      */

94     private String JavaDoc ignoreExpr;
95     /**
96      * Instance variable mapped to "role" tag attribute.
97      * (Mapping set in associated BeanInfo class.)
98      */

99     private String JavaDoc roleExpr;
100     /**
101      * Instance variable mapped to "controllerUrl" tag attribute.
102      * (Mapping set in associated BeanInfo class.)
103      */

104     private String JavaDoc controllerUrlExpr;
105     /**
106      * Instance variable mapped to "controllerClass" tag attribute.
107      * (Mapping set in associated BeanInfo class.)
108      */

109     private String JavaDoc controllerClassExpr;
110
111     /**
112      * Getter method for "template" tag attribute.
113      * (Mapping set in associated BeanInfo class.)
114      */

115     public String JavaDoc getTemplateExpr() { return (templateExpr); }
116     /**
117      * Getter method for "component" tag attribute.
118      * (Mapping set in associated BeanInfo class.)
119      */

120     public String JavaDoc getComponentExpr() { return (componentExpr); }
121     /**
122      * Getter method for "page" tag attribute.
123      * (Mapping set in associated BeanInfo class.)
124      */

125     public String JavaDoc getPageExpr() { return (pageExpr); }
126     /**
127      * Getter method for "definition" tag attribute.
128      * (Mapping set in associated BeanInfo class.)
129      */

130     public String JavaDoc getDefinitionExpr() { return (definitionExpr); }
131     /**
132      * Getter method for "attribute" tag attribute.
133      * (Mapping set in associated BeanInfo class.)
134      */

135     public String JavaDoc getAttributeExpr() { return (attributeExpr); }
136     /**
137      * Getter method for "name" tag attribute.
138      * (Mapping set in associated BeanInfo class.)
139      */

140     public String JavaDoc getNameExpr() { return (nameExpr); }
141     /**
142      * Getter method for "beanName" tag attribute.
143      * (Mapping set in associated BeanInfo class.)
144      */

145     public String JavaDoc getBeanNameExpr() { return (beanNameExpr); }
146     /**
147      * Getter method for "beanProperty" tag attribute.
148      * (Mapping set in associated BeanInfo class.)
149      */

150     public String JavaDoc getBeanPropertyExpr() { return (beanPropertyExpr); }
151     /**
152      * Getter method for "beanScope" tag attribute.
153      * (Mapping set in associated BeanInfo class.)
154      */

155     public String JavaDoc getBeanScopeExpr() { return (beanScopeExpr); }
156     /**
157      * Getter method for "flush" tag attribute.
158      * (Mapping set in associated BeanInfo class.)
159      */

160     public String JavaDoc getFlushExpr() { return (flushExpr); }
161     /**
162      * Getter method for "ignore" tag attribute.
163      * (Mapping set in associated BeanInfo class.)
164      */

165     public String JavaDoc getIgnoreExpr() { return (ignoreExpr); }
166     /**
167      * Getter method for "role" tag attribute.
168      * (Mapping set in associated BeanInfo class.)
169      */

170     public String JavaDoc getRoleExpr() { return (roleExpr); }
171     /**
172      * Getter method for "controllerUrl" tag attribute.
173      * (Mapping set in associated BeanInfo class.)
174      */

175     public String JavaDoc getControllerUrlExpr() { return (controllerUrlExpr); }
176     /**
177      * Getter method for "controllerClass" tag attribute.
178      * (Mapping set in associated BeanInfo class.)
179      */

180     public String JavaDoc getControllerClassExpr() { return (controllerClassExpr); }
181
182     /**
183      * Setter method for "template" tag attribute.
184      * (Mapping set in associated BeanInfo class.)
185      */

186     public void setTemplateExpr(String JavaDoc templateExpr) { this.templateExpr = templateExpr; }
187     /**
188      * Setter method for "component" tag attribute.
189      * (Mapping set in associated BeanInfo class.)
190      */

191     public void setComponentExpr(String JavaDoc componentExpr) { this.componentExpr = componentExpr; }
192     /**
193      * Setter method for "page" tag attribute.
194      * (Mapping set in associated BeanInfo class.)
195      */

196     public void setPageExpr(String JavaDoc pageExpr) { this.pageExpr = pageExpr; }
197     /**
198      * Setter method for "definition" tag attribute.
199      * (Mapping set in associated BeanInfo class.)
200      */

201     public void setDefinitionExpr(String JavaDoc definitionExpr) { this.definitionExpr = definitionExpr; }
202     /**
203      * Setter method for "attribute" tag attribute.
204      * (Mapping set in associated BeanInfo class.)
205      */

206     public void setAttributeExpr(String JavaDoc attributeExpr) { this.attributeExpr = attributeExpr; }
207     /**
208      * Setter method for "name" tag attribute.
209      * (Mapping set in associated BeanInfo class.)
210      */

211     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
212     /**
213      * Setter method for "beanName" tag attribute.
214      * (Mapping set in associated BeanInfo class.)
215      */

216     public void setBeanNameExpr(String JavaDoc beanNameExpr) { this.beanNameExpr = beanNameExpr; }
217     /**
218      * Setter method for "beanProperty" tag attribute.
219      * (Mapping set in associated BeanInfo class.)
220      */

221     public void setBeanPropertyExpr(String JavaDoc beanPropertyExpr) { this.beanPropertyExpr = beanPropertyExpr; }
222     /**
223      * Setter method for "beanScope" tag attribute.
224      * (Mapping set in associated BeanInfo class.)
225      */

226     public void setBeanScopeExpr(String JavaDoc beanScopeExpr) { this.beanScopeExpr = beanScopeExpr; }
227     /**
228      * Setter method for "flush" tag attribute.
229      * (Mapping set in associated BeanInfo class.)
230      */

231     public void setFlushExpr(String JavaDoc flushExpr) { this.flushExpr = flushExpr; }
232     /**
233      * Setter method for "ignore" tag attribute.
234      * (Mapping set in associated BeanInfo class.)
235      */

236     public void setIgnoreExpr(String JavaDoc ignoreExpr) { this.ignoreExpr = ignoreExpr; }
237     /**
238      * Setter method for "role" tag attribute.
239      * (Mapping set in associated BeanInfo class.)
240      */

241     public void setRoleExpr(String JavaDoc roleExpr) { this.roleExpr = roleExpr; }
242     /**
243      * Setter method for "controllerUrl" tag attribute.
244      * (Mapping set in associated BeanInfo class.)
245      */

246     public void setControllerUrlExpr(String JavaDoc controllerUrlExpr) { this.controllerUrlExpr = controllerUrlExpr; }
247     /**
248      * Setter method for "controllerClass" tag attribute.
249      * (Mapping set in associated BeanInfo class.)
250      */

251     public void setControllerClassExpr(String JavaDoc controllerClassExpr) { this.controllerClassExpr = controllerClassExpr; }
252
253     /**
254      * Resets attribute values for tag reuse.
255      */

256     public void release()
257     {
258         super.release();
259         setTemplateExpr(null);
260         setComponentExpr(null);
261         setPageExpr(null);
262         setDefinitionExpr(null);
263         setAttributeExpr(null);
264         setNameExpr(null);
265         setBeanNameExpr(null);
266         setBeanPropertyExpr(null);
267         setBeanScopeExpr(null);
268         setFlushExpr(null);
269         setIgnoreExpr(null);
270         setRoleExpr(null);
271         setControllerUrlExpr(null);
272         setControllerClassExpr(null);
273     }
274     
275     /**
276      * Process the start tag.
277      *
278      * @exception JspException if a JSP exception has occurred
279      */

280     public int doStartTag() throws JspException JavaDoc {
281         evaluateExpressions();
282         return (super.doStartTag());
283     }
284     
285     /**
286      * Processes all attribute values which use the JSTL expression evaluation
287      * engine to determine their values.
288      *
289      * @exception JspException if a JSP exception has occurred
290      */

291     private void evaluateExpressions() throws JspException JavaDoc {
292         String JavaDoc string = null;
293         Boolean JavaDoc bool = null;
294
295         if ((string = EvalHelper.evalString("template", getTemplateExpr(),
296                                             this, pageContext)) != null)
297             setTemplate(string);
298         if ((string = EvalHelper.evalString("component", getComponentExpr(),
299                                             this, pageContext)) != null)
300             setComponent(string);
301         if ((string = EvalHelper.evalString("page", getPageExpr(),
302                                             this, pageContext)) != null)
303             setPage(string);
304         if ((string = EvalHelper.evalString("definition", getDefinitionExpr(),
305                                             this, pageContext)) != null)
306             setDefinition(string);
307         if ((string = EvalHelper.evalString("attribute", getAttributeExpr(),
308                                             this, pageContext)) != null)
309             setAttribute(string);
310         if ((string = EvalHelper.evalString("name", getNameExpr(),
311                                             this, pageContext)) != null)
312             setName(string);
313         if ((string = EvalHelper.evalString("beanName", getBeanNameExpr(),
314                                             this, pageContext)) != null)
315             setBeanName(string);
316         if ((string = EvalHelper.evalString("beanProperty", getBeanPropertyExpr(),
317                                             this, pageContext)) != null)
318             setBeanProperty(string);
319         if ((string = EvalHelper.evalString("beanScope", getBeanScopeExpr(),
320                                             this, pageContext)) != null)
321             setBeanScope(string);
322         if ((string = EvalHelper.evalString("flush", getFlushExpr(),
323                                             this, pageContext)) != null)
324             setFlush(string);
325         if ((bool = EvalHelper.evalBoolean("ignore", getIgnoreExpr(),
326                                            this, pageContext)) != null)
327             setIgnore(bool.booleanValue());
328         if ((string = EvalHelper.evalString("role", getRoleExpr(),
329                                             this, pageContext)) != null)
330             setRole(string);
331         if ((string = EvalHelper.evalString("controllerUrl", getControllerUrlExpr(),
332                                             this, pageContext)) != null)
333             setControllerUrl(string);
334         if ((string = EvalHelper.evalString("controllerClass", getControllerClassExpr(),
335                                             this, pageContext)) != null)
336             setControllerClass(string);
337     }
338 }
339
Popular Tags