KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELDefinitionTag.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.DefinitionTag;
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:definition>, which defines
27  * a tiles (or template / component). Definition is put in requested context and can be
28  * used in <tiles:insert&gt.
29  *<p>
30  * This class is a subclass of the class
31  * <code>org.apache.struts.taglib.tiles.DefinitionTag</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 ELDefinitionTag extends DefinitionTag {
39
40     /**
41      * Instance variable mapped to "id" tag attribute.
42      * (Mapping set in associated BeanInfo class.)
43      */

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

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

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

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

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

69     private String JavaDoc extendsExpr;
70
71     /**
72      * Getter method for "id" tag attribute.
73      * (Mapping set in associated BeanInfo class.)
74      */

75     public String JavaDoc getIdExpr() { return (idExpr); }
76     /**
77      * Getter method for "scope" tag attribute.
78      * (Mapping set in associated BeanInfo class.)
79      */

80     public String JavaDoc getScopeExpr() { return (scopeExpr); }
81     /**
82      * Getter method for "template" tag attribute.
83      * (Mapping set in associated BeanInfo class.)
84      */

85     public String JavaDoc getTemplateExpr() { return (templateExpr); }
86     /**
87      * Getter method for "page" tag attribute.
88      * (Mapping set in associated BeanInfo class.)
89      */

90     public String JavaDoc getPageExpr() { return (pageExpr); }
91     /**
92      * Getter method for "role" tag attribute.
93      * (Mapping set in associated BeanInfo class.)
94      */

95     public String JavaDoc getRoleExpr() { return (roleExpr); }
96     /**
97      * Getter method for "extends" tag attribute.
98      * (Mapping set in associated BeanInfo class.)
99      */

100     public String JavaDoc getExtendsExpr() { return (extendsExpr); }
101
102     /**
103      * Setter method for "id" tag attribute.
104      * (Mapping set in associated BeanInfo class.)
105      */

106     public void setIdExpr(String JavaDoc idExpr) { this.idExpr = idExpr; }
107     /**
108      * Setter method for "scope" tag attribute.
109      * (Mapping set in associated BeanInfo class.)
110      */

111     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
112     /**
113      * Setter method for "template" tag attribute.
114      * (Mapping set in associated BeanInfo class.)
115      */

116     public void setTemplateExpr(String JavaDoc templateExpr) { this.templateExpr = templateExpr; }
117     /**
118      * Setter method for "page" tag attribute.
119      * (Mapping set in associated BeanInfo class.)
120      */

121     public void setPageExpr(String JavaDoc pageExpr) { this.pageExpr = pageExpr; }
122     /**
123      * Setter method for "role" tag attribute.
124      * (Mapping set in associated BeanInfo class.)
125      */

126     public void setRoleExpr(String JavaDoc roleExpr) { this.roleExpr = roleExpr; }
127     /**
128      * Setter method for "extends" tag attribute.
129      * (Mapping set in associated BeanInfo class.)
130      */

131     public void setExtendsExpr(String JavaDoc extendsExpr) { this.extendsExpr = extendsExpr; }
132
133     /**
134      * Resets attribute values for tag reuse.
135      */

136     public void release()
137     {
138         super.release();
139         setIdExpr(null);
140         setScopeExpr(null);
141         setTemplateExpr(null);
142         setPageExpr(null);
143         setRoleExpr(null);
144         setExtendsExpr(null);
145     }
146     
147     /**
148      * Process the start tag.
149      *
150      * @exception JspException if a JSP exception has occurred
151      */

152     public int doStartTag() throws JspException JavaDoc {
153         evaluateExpressions();
154         return (super.doStartTag());
155     }
156     
157     /**
158      * Processes all attribute values which use the JSTL expression evaluation
159      * engine to determine their values.
160      *
161      * @exception JspException if a JSP exception has occurred
162      */

163     private void evaluateExpressions() throws JspException JavaDoc {
164         String JavaDoc string = null;
165
166         if ((string = EvalHelper.evalString("id", getIdExpr(),
167                                             this, pageContext)) != null)
168             setId(string);
169         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
170                                             this, pageContext)) != null)
171             setScope(string);
172         if ((string = EvalHelper.evalString("template", getTemplateExpr(),
173                                             this, pageContext)) != null)
174             setTemplate(string);
175         if ((string = EvalHelper.evalString("page", getPageExpr(),
176                                             this, pageContext)) != null)
177             setPage(string);
178         if ((string = EvalHelper.evalString("role", getRoleExpr(),
179                                             this, pageContext)) != null)
180             setRole(string);
181         if ((string = EvalHelper.evalString("extends", getExtendsExpr(),
182                                             this, pageContext)) != null)
183             setExtends(string);
184     }
185 }
186
Popular Tags