1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.strutsel.taglib.tiles;
19
20 import org.apache.struts.tiles.taglib.DefinitionTag;
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:definition>, which defines a tiles
27 * (or template / component). Definition is put in requested context and can
28 * be used in <tiles:insert>. <p> This class is a subclass of the class
29 * <code>org.apache.struts.taglib.tiles.DefinitionTag</code> which provides
30 * most of the described functionality. This subclass allows all attribute
31 * values to be specified as expressions utilizing the JavaServer Pages
32 * Standard Library expression language.
33 *
34 * @version $Rev: 376781 $
35 */
36 public class ELDefinitionTag extends DefinitionTag {
37 /***
38 * Instance variable mapped to "id" tag attribute. (Mapping set in
39 * associated BeanInfo class.)
40 */
41 private String idExpr;
42
43 /***
44 * Instance variable mapped to "scope" tag attribute. (Mapping set in
45 * associated BeanInfo class.)
46 */
47 private String scopeExpr;
48
49 /***
50 * Instance variable mapped to "template" tag attribute. (Mapping set in
51 * associated BeanInfo class.)
52 */
53 private String templateExpr;
54
55 /***
56 * Instance variable mapped to "page" tag attribute. (Mapping set in
57 * associated BeanInfo class.)
58 */
59 private String pageExpr;
60
61 /***
62 * Instance variable mapped to "role" tag attribute. (Mapping set in
63 * associated BeanInfo class.)
64 */
65 private String roleExpr;
66
67 /***
68 * Instance variable mapped to "extends" tag attribute. (Mapping set in
69 * associated BeanInfo class.)
70 */
71 private String extendsExpr;
72
73 /***
74 * Getter method for "id" tag attribute. (Mapping set in associated
75 * BeanInfo class.)
76 */
77 public String getIdExpr() {
78 return (idExpr);
79 }
80
81 /***
82 * Getter method for "scope" tag attribute. (Mapping set in associated
83 * BeanInfo class.)
84 */
85 public String getScopeExpr() {
86 return (scopeExpr);
87 }
88
89 /***
90 * Getter method for "template" tag attribute. (Mapping set in associated
91 * BeanInfo class.)
92 */
93 public String getTemplateExpr() {
94 return (templateExpr);
95 }
96
97 /***
98 * Getter method for "page" tag attribute. (Mapping set in associated
99 * BeanInfo class.)
100 */
101 public String getPageExpr() {
102 return (pageExpr);
103 }
104
105 /***
106 * Getter method for "role" tag attribute. (Mapping set in associated
107 * BeanInfo class.)
108 */
109 public String getRoleExpr() {
110 return (roleExpr);
111 }
112
113 /***
114 * Getter method for "extends" tag attribute. (Mapping set in associated
115 * BeanInfo class.)
116 */
117 public String getExtendsExpr() {
118 return (extendsExpr);
119 }
120
121 /***
122 * Setter method for "id" tag attribute. (Mapping set in associated
123 * BeanInfo class.)
124 */
125 public void setIdExpr(String idExpr) {
126 this.idExpr = idExpr;
127 }
128
129 /***
130 * Setter method for "scope" tag attribute. (Mapping set in associated
131 * BeanInfo class.)
132 */
133 public void setScopeExpr(String scopeExpr) {
134 this.scopeExpr = scopeExpr;
135 }
136
137 /***
138 * Setter method for "template" tag attribute. (Mapping set in associated
139 * BeanInfo class.)
140 */
141 public void setTemplateExpr(String templateExpr) {
142 this.templateExpr = templateExpr;
143 }
144
145 /***
146 * Setter method for "page" tag attribute. (Mapping set in associated
147 * BeanInfo class.)
148 */
149 public void setPageExpr(String pageExpr) {
150 this.pageExpr = pageExpr;
151 }
152
153 /***
154 * Setter method for "role" tag attribute. (Mapping set in associated
155 * BeanInfo class.)
156 */
157 public void setRoleExpr(String roleExpr) {
158 this.roleExpr = roleExpr;
159 }
160
161 /***
162 * Setter method for "extends" tag attribute. (Mapping set in associated
163 * BeanInfo class.)
164 */
165 public void setExtendsExpr(String extendsExpr) {
166 this.extendsExpr = extendsExpr;
167 }
168
169 /***
170 * Resets attribute values for tag reuse.
171 */
172 public void release() {
173 super.release();
174 setIdExpr(null);
175 setScopeExpr(null);
176 setTemplateExpr(null);
177 setPageExpr(null);
178 setRoleExpr(null);
179 setExtendsExpr(null);
180 }
181
182 /***
183 * Process the start tag.
184 *
185 * @throws JspException if a JSP exception has occurred
186 */
187 public int doStartTag() throws JspException {
188 evaluateExpressions();
189
190 return (super.doStartTag());
191 }
192
193 /***
194 * Processes all attribute values which use the JSTL expression evaluation
195 * engine to determine their values.
196 *
197 * @throws JspException if a JSP exception has occurred
198 */
199 private void evaluateExpressions()
200 throws JspException {
201 String string = null;
202
203 if ((string =
204 EvalHelper.evalString("id", getIdExpr(), this, pageContext)) != null) {
205 setId(string);
206 }
207
208 if ((string =
209 EvalHelper.evalString("scope", getScopeExpr(), this, pageContext)) != null) {
210 setScope(string);
211 }
212
213 if ((string =
214 EvalHelper.evalString("template", getTemplateExpr(), this,
215 pageContext)) != null) {
216 setTemplate(string);
217 }
218
219 if ((string =
220 EvalHelper.evalString("page", getPageExpr(), this, pageContext)) != null) {
221 setPage(string);
222 }
223
224 if ((string =
225 EvalHelper.evalString("role", getRoleExpr(), this, pageContext)) != null) {
226 setRole(string);
227 }
228
229 if ((string =
230 EvalHelper.evalString("extends", getExtendsExpr(), this,
231 pageContext)) != null) {
232 setExtends(string);
233 }
234 }
235 }