KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > html > ELJavascriptValidatorTag


1 /*
2  * $Id: ELJavascriptValidatorTag.java 160033 2005-04-04 12:06:45Z niallp $
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.html;
20
21 import org.apache.struts.taglib.html.JavascriptValidatorTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Custom tag that generates JavaScript for client side validation based
27  * on the validation rules loaded by the <code>ValidatorPlugIn</code>
28  * defined in the struts-config.xml file.
29  *<p>
30  * This class is a subclass of the class
31  * <code>org.apache.struts.taglib.html.JavascriptValidatorTag</code> which
32  * provides most of the described functionality. This subclass allows all
33  * attribute values to be specified as expressions utilizing the JavaServer
34  * Pages Standard Library expression language.
35  *
36  * @version $Rev: 160033 $
37  */

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

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

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

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

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

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

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

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

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

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

89     private String JavaDoc bundleExpr;
90
91     /**
92      * Getter method for "cdata" tag attribute.
93      * (Mapping set in associated BeanInfo class.)
94      */

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

100     public String JavaDoc getDynamicJavascriptExpr() { return (dynamicJavascriptExpr); }
101     /**
102      * Getter method for "formName" tag attribute.
103      * (Mapping set in associated BeanInfo class.)
104      */

105     public String JavaDoc getFormNameExpr() { return (formNameExpr); }
106     /**
107      * Getter method for "method" tag attribute.
108      * (Mapping set in associated BeanInfo class.)
109      */

110     public String JavaDoc getMethodExpr() { return (methodExpr); }
111     /**
112      * Getter method for "page" tag attribute.
113      * (Mapping set in associated BeanInfo class.)
114      */

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

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

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

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

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

140     public String JavaDoc getBundleExpr() { return (bundleExpr); }
141
142     /**
143      * Setter method for "cdata" tag attribute.
144      * (Mapping set in associated BeanInfo class.)
145      */

146     public void setCdataExpr(String JavaDoc cdataExpr) { this.cdataExpr = cdataExpr; }
147     /**
148      * Setter method for "dynamicJavascript" tag attribute.
149      * (Mapping set in associated BeanInfo class.)
150      */

151     public void setDynamicJavascriptExpr(String JavaDoc dynamicJavascriptExpr) { this.dynamicJavascriptExpr = dynamicJavascriptExpr; }
152     /**
153      * Setter method for "formName" tag attribute.
154      * (Mapping set in associated BeanInfo class.)
155      */

156     public void setFormNameExpr(String JavaDoc formNameExpr) { this.formNameExpr = formNameExpr; }
157     /**
158      * Setter method for "method" tag attribute.
159      * (Mapping set in associated BeanInfo class.)
160      */

161     public void setMethodExpr(String JavaDoc methodExpr) { this.methodExpr = methodExpr; }
162     /**
163      * Setter method for "page" tag attribute.
164      * (Mapping set in associated BeanInfo class.)
165      */

166     public void setPageExpr(String JavaDoc pageExpr) { this.pageExpr = pageExpr; }
167     /**
168      * Setter method for "scriptLanguage" tag attribute.
169      * (Mapping set in associated BeanInfo class.)
170      */

171     public void setScriptLanguageExpr(String JavaDoc scriptLanguageExpr) { this.scriptLanguageExpr = scriptLanguageExpr; }
172     /**
173      * Setter method for "src" tag attribute.
174      * (Mapping set in associated BeanInfo class.)
175      */

176     public void setSrcExpr(String JavaDoc srcExpr) { this.srcExpr = srcExpr; }
177     /**
178      * Setter method for "staticJavascript" tag attribute.
179      * (Mapping set in associated BeanInfo class.)
180      */

181     public void setStaticJavascriptExpr(String JavaDoc staticJavascriptExpr) { this.staticJavascriptExpr = staticJavascriptExpr; }
182     /**
183      * Setter method for "htmlComment" tag attribute.
184      * (Mapping set in associated BeanInfo class.)
185      */

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

191     public void setBundleExpr(String JavaDoc bundleExpr) { this.bundleExpr = bundleExpr; }
192
193     /**
194      * Resets attribute values for tag reuse.
195      */

196     public void release()
197     {
198         super.release();
199         setCdataExpr(null);
200         setDynamicJavascriptExpr(null);
201         setFormNameExpr(null);
202         setMethodExpr(null);
203         setPageExpr(null);
204         setScriptLanguageExpr(null);
205         setSrcExpr(null);
206         setStaticJavascriptExpr(null);
207         setHtmlCommentExpr(null);
208         setBundleExpr(null);
209     }
210
211     /**
212      * Process the start tag.
213      *
214      * @exception JspException if a JSP exception has occurred
215      */

216     public int doStartTag() throws JspException JavaDoc {
217         evaluateExpressions();
218         return (super.doStartTag());
219     }
220     
221     /**
222      * Processes all attribute values which use the JSTL expression evaluation
223      * engine to determine their values.
224      *
225      * @exception JspException if a JSP exception has occurred
226      */

227     private void evaluateExpressions() throws JspException JavaDoc {
228         String JavaDoc string = null;
229         Integer JavaDoc integer = null;
230         Boolean JavaDoc bool = null;
231
232         if ((string = EvalHelper.evalString("cdata", getCdataExpr(),
233                                             this, pageContext)) != null)
234             setCdata(string);
235
236         if ((string = EvalHelper.evalString("dynamicJavascript", getDynamicJavascriptExpr(),
237                                             this, pageContext)) != null)
238             setDynamicJavascript(string);
239
240         if ((string = EvalHelper.evalString("formName", getFormNameExpr(),
241                                             this, pageContext)) != null)
242             setFormName(string);
243
244         if ((string = EvalHelper.evalString("method", getMethodExpr(),
245                                             this, pageContext)) != null)
246             setMethod(string);
247
248         if ((integer = EvalHelper.evalInteger("page", getPageExpr(),
249                                               this, pageContext)) != null)
250             setPage(integer.intValue());
251
252         if ((bool = EvalHelper.evalBoolean("scriptLanguage", getScriptLanguageExpr(),
253                                            this, pageContext)) != null)
254             setScriptLanguage(bool.booleanValue());
255
256         if ((string = EvalHelper.evalString("src", getSrcExpr(),
257                                             this, pageContext)) != null)
258             setSrc(string);
259
260         if ((string = EvalHelper.evalString("staticJavascript", getStaticJavascriptExpr(),
261                                             this, pageContext)) != null)
262             setStaticJavascript(string);
263
264         if ((string = EvalHelper.evalString("htmlComment", getHtmlCommentExpr(),
265                                             this, pageContext)) != null)
266             setHtmlComment(string);
267
268         if ((string = EvalHelper.evalString("bundle", getBundleExpr(),
269                                             this, pageContext)) != null)
270             setBundle(string);
271     }
272 }
273
Popular Tags