KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > bean > ELMessageTag


1 /*
2  * $Id: ELMessageTag.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.bean;
20
21 import javax.servlet.jsp.JspException JavaDoc;
22
23 import org.apache.struts.taglib.bean.MessageTag;
24 import org.apache.strutsel.taglib.utils.EvalHelper;
25
26 /**
27  * Custom tag that retrieves an internationalized messages string (with
28  * optional parametric replacement) from the <code>ActionResources</code>
29  * object stored as a context attribute by our associated
30  * <code>ActionServlet</code> implementation.
31  *<p>
32  * This class is a subclass of the class
33  * <code>org.apache.struts.taglib.bean.MessageTag</code> which provides most of
34  * the described functionality. This subclass allows all attribute values to
35  * be specified as expressions utilizing the JavaServer Pages Standard Library
36  * expression language.
37  *
38  * @version $Rev: 54933 $
39  */

40 public class ELMessageTag extends MessageTag {
41
42     /**
43      * Instance variable mapped to "arg0" tag attribute.
44      * (Mapping set in associated BeanInfo class.)
45      */

46     private String JavaDoc arg0Expr;
47     /**
48      * Instance variable mapped to "arg1" tag attribute.
49      * (Mapping set in associated BeanInfo class.)
50      */

51     private String JavaDoc arg1Expr;
52     /**
53      * Instance variable mapped to "arg2" tag attribute.
54      * (Mapping set in associated BeanInfo class.)
55      */

56     private String JavaDoc arg2Expr;
57     /**
58      * Instance variable mapped to "arg3" tag attribute.
59      * (Mapping set in associated BeanInfo class.)
60      */

61     private String JavaDoc arg3Expr;
62     /**
63      * Instance variable mapped to "arg4" tag attribute.
64      * (Mapping set in associated BeanInfo class.)
65      */

66     private String JavaDoc arg4Expr;
67     /**
68      * Instance variable mapped to "bundle" tag attribute.
69      * (Mapping set in associated BeanInfo class.)
70      */

71     private String JavaDoc bundleExpr;
72     /**
73      * Instance variable mapped to "key" tag attribute.
74      * (Mapping set in associated BeanInfo class.)
75      */

76     private String JavaDoc keyExpr;
77     /**
78      * Instance variable mapped to "locale" tag attribute.
79      * (Mapping set in associated BeanInfo class.)
80      */

81     private String JavaDoc localeExpr;
82     /**
83      * Instance variable mapped to "name" tag attribute.
84      * (Mapping set in associated BeanInfo class.)
85      */

86     private String JavaDoc nameExpr;
87     /**
88      * Instance variable mapped to "property" tag attribute.
89      * (Mapping set in associated BeanInfo class.)
90      */

91     private String JavaDoc propertyExpr;
92     /**
93      * Instance variable mapped to "scope" tag attribute.
94      * (Mapping set in associated BeanInfo class.)
95      */

96     private String JavaDoc scopeExpr;
97
98     /**
99      * Getter method for "arg0" tag attribute.
100      * (Mapping set in associated BeanInfo class.)
101      */

102     public String JavaDoc getArg0Expr() { return (arg0Expr); }
103     /**
104      * Getter method for "arg1" tag attribute.
105      * (Mapping set in associated BeanInfo class.)
106      */

107     public String JavaDoc getArg1Expr() { return (arg1Expr); }
108     /**
109      * Getter method for "arg2" tag attribute.
110      * (Mapping set in associated BeanInfo class.)
111      */

112     public String JavaDoc getArg2Expr() { return (arg2Expr); }
113     /**
114      * Getter method for "arg3" tag attribute.
115      * (Mapping set in associated BeanInfo class.)
116      */

117     public String JavaDoc getArg3Expr() { return (arg3Expr); }
118     /**
119      * Getter method for "arg4" tag attribute.
120      * (Mapping set in associated BeanInfo class.)
121      */

122     public String JavaDoc getArg4Expr() { return (arg4Expr); }
123     /**
124      * Getter method for "bundle" tag attribute.
125      * (Mapping set in associated BeanInfo class.)
126      */

127     public String JavaDoc getBundleExpr() { return (bundleExpr); }
128     /**
129      * Getter method for "key" tag attribute.
130      * (Mapping set in associated BeanInfo class.)
131      */

132     public String JavaDoc getKeyExpr() { return (keyExpr); }
133     /**
134      * Getter method for "locale" tag attribute.
135      * (Mapping set in associated BeanInfo class.)
136      */

137     public String JavaDoc getLocaleExpr() { return (localeExpr); }
138     /**
139      * Getter method for "name" tag attribute.
140      * (Mapping set in associated BeanInfo class.)
141      */

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

147     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
148     /**
149      * Getter method for "scope" tag attribute.
150      * (Mapping set in associated BeanInfo class.)
151      */

152     public String JavaDoc getScopeExpr() { return (scopeExpr); }
153
154     /**
155      * Setter method for "arg0" tag attribute.
156      * (Mapping set in associated BeanInfo class.)
157      */

158     public void setArg0Expr(String JavaDoc arg0Expr) { this.arg0Expr = arg0Expr; }
159     /**
160      * Setter method for "arg1" tag attribute.
161      * (Mapping set in associated BeanInfo class.)
162      */

163     public void setArg1Expr(String JavaDoc arg1Expr) { this.arg1Expr = arg1Expr; }
164     /**
165      * Setter method for "arg2" tag attribute.
166      * (Mapping set in associated BeanInfo class.)
167      */

168     public void setArg2Expr(String JavaDoc arg2Expr) { this.arg2Expr = arg2Expr; }
169     /**
170      * Setter method for "arg3" tag attribute.
171      * (Mapping set in associated BeanInfo class.)
172      */

173     public void setArg3Expr(String JavaDoc arg3Expr) { this.arg3Expr = arg3Expr; }
174     /**
175      * Setter method for "arg4" tag attribute.
176      * (Mapping set in associated BeanInfo class.)
177      */

178     public void setArg4Expr(String JavaDoc arg4Expr) { this.arg4Expr = arg4Expr; }
179     /**
180      * Setter method for "bundle" tag attribute.
181      * (Mapping set in associated BeanInfo class.)
182      */

183     public void setBundleExpr(String JavaDoc bundleExpr) { this.bundleExpr = bundleExpr; }
184     /**
185      * Setter method for "key" tag attribute.
186      * (Mapping set in associated BeanInfo class.)
187      */

188     public void setKeyExpr(String JavaDoc keyExpr) { this.keyExpr = keyExpr; }
189     /**
190      * Setter method for "locale" tag attribute.
191      * (Mapping set in associated BeanInfo class.)
192      */

193     public void setLocaleExpr(String JavaDoc localeExpr) { this.localeExpr = localeExpr; }
194     /**
195      * Setter method for "name" tag attribute.
196      * (Mapping set in associated BeanInfo class.)
197      */

198     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
199     /**
200      * Setter method for "property" tag attribute.
201      * (Mapping set in associated BeanInfo class.)
202      */

203     public void setPropertyExpr(String JavaDoc propertyExpr) { this.propertyExpr = propertyExpr; }
204     /**
205      * Setter method for "scope" tag attribute.
206      * (Mapping set in associated BeanInfo class.)
207      */

208     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
209
210     /**
211      * Resets attribute values for tag reuse.
212      */

213     public void release()
214     {
215         super.release();
216         setArg0Expr(null);
217         setArg1Expr(null);
218         setArg2Expr(null);
219         setArg3Expr(null);
220         setArg4Expr(null);
221         setBundleExpr(null);
222         setKeyExpr(null);
223         setLocaleExpr(null);
224         setNameExpr(null);
225         setPropertyExpr(null);
226         setScopeExpr(null);
227     }
228     
229     /**
230      * Process the start tag.
231      *
232      * @exception JspException if a JSP exception has occurred
233      */

234     public int doStartTag() throws JspException JavaDoc {
235         evaluateExpressions();
236         return (super.doStartTag());
237     }
238
239     /**
240      * Processes all attribute values which use the JSTL expression evaluation
241      * engine to determine their values.
242      *
243      * @exception JspException if a JSP exception has occurred
244      */

245     private void evaluateExpressions() throws JspException JavaDoc {
246         String JavaDoc string = null;
247
248
249         if ((string = EvalHelper.evalString("arg0", getArg0Expr(),
250                                             this, pageContext)) != null)
251             setArg0(string);
252
253         if ((string = EvalHelper.evalString("arg1", getArg1Expr(),
254                                             this, pageContext)) != null)
255             setArg1(string);
256
257         if ((string = EvalHelper.evalString("arg2", getArg2Expr(),
258                                             this, pageContext)) != null)
259             setArg2(string);
260
261         if ((string = EvalHelper.evalString("arg3", getArg3Expr(),
262                                             this, pageContext)) != null)
263             setArg3(string);
264
265         if ((string = EvalHelper.evalString("arg4", getArg4Expr(),
266                                             this, pageContext)) != null)
267             setArg4(string);
268
269         if ((string = EvalHelper.evalString("bundle", getBundleExpr(),
270                                             this, pageContext)) != null)
271             setBundle(string);
272
273         if ((string = EvalHelper.evalString("key", getKeyExpr(),
274                                             this, pageContext)) != null)
275             setKey(string);
276
277         if ((string = EvalHelper.evalString("locale", getLocaleExpr(),
278                                             this, pageContext)) != null)
279             setLocale(string);
280
281         if ((string = EvalHelper.evalString("name", getNameExpr(),
282                                             this, pageContext)) != null)
283             setName(string);
284
285         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
286                                             this, pageContext)) != null)
287             setProperty(string);
288
289         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
290                                             this, pageContext)) != null)
291             setScope(string);
292     }
293 }
294
Popular Tags