2
* $Header: /home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELJavascriptValidatorTag.java,v 1.12 2004/03/14 07:15:01 sraeburn Exp $
4
* $Date: 2004/03/14 07:15:01 $
6
* Copyright 1999-2004 The Apache Software Foundation.
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
21
package org.apache.strutsel.taglib.html;
23
import org.apache.struts.taglib.html.JavascriptValidatorTag;
24
import javax.servlet.jsp.JspException;
25
import org.apache.strutsel.taglib.utils.EvalHelper;
28
* Custom tag that generates JavaScript for client side validation based
29
* on the validation rules loaded by the <code>ValidatorPlugIn</code>
30
* defined in the struts-config.xml file.
32
* This class is a subclass of the class
33
* <code>org.apache.struts.taglib.html.JavascriptValidatorTag</code> which
34
* provides most of the described functionality. This subclass allows all
35
* attribute values to be specified as expressions utilizing the JavaServer
36
* Pages Standard Library expression language.
38
* @version $Revision: 1.12 $
40
public class ELJavascriptValidatorTag extends JavascriptValidatorTag {
43
* Instance variable mapped to "cdata" tag attribute.
44
* (Mapping set in associated BeanInfo class.)
46
private String cdataExpr;
48
* Instance variable mapped to "dynamicJavascript" tag attribute.
49
* (Mapping set in associated BeanInfo class.)
51
private String dynamicJavascriptExpr;
53
* Instance variable mapped to "formName" tag attribute.
54
* (Mapping set in associated BeanInfo class.)
56
private String formNameExpr;
58
* Instance variable mapped to "method" tag attribute.
59
* (Mapping set in associated BeanInfo class.)
61
private String methodExpr;
63
* Instance variable mapped to "page" tag attribute.
64
* (Mapping set in associated BeanInfo class.)
66
private String pageExpr;
68
* Instance variable mapped to "scriptLanguage" tag attribute.
69
* (Mapping set in associated BeanInfo class.)
71
private String scriptLanguageExpr;
73
* Instance variable mapped to "src" tag attribute.
74
* (Mapping set in associated BeanInfo class.)
76
private String srcExpr;
78
* Instance variable mapped to "staticJavascript" tag attribute.
79
* (Mapping set in associated BeanInfo class.)
81
private String staticJavascriptExpr;
83
* Instance variable mapped to "htmlComment" tag attribute.
84
* (Mapping set in associated BeanInfo class.)
86
private String htmlCommentExpr;
89
* Getter method for "cdata" tag attribute.
90
* (Mapping set in associated BeanInfo class.)
92
public String getCdataExpr() { return (cdataExpr); }
94
* Getter method for "dynamicJavascript" tag attribute.
95
* (Mapping set in associated BeanInfo class.)
97
public String getDynamicJavascriptExpr() { return (dynamicJavascriptExpr); }
99
* Getter method for "formName" tag attribute.
100
* (Mapping set in associated BeanInfo class.)
102
public String getFormNameExpr() { return (formNameExpr); }
104
* Getter method for "method" tag attribute.
105
* (Mapping set in associated BeanInfo class.)
107
public String getMethodExpr() { return (methodExpr); }
109
* Getter method for "page" tag attribute.
110
* (Mapping set in associated BeanInfo class.)
112
public String getPageExpr() { return (pageExpr); }
114
* Getter method for "scriptLanguage" tag attribute.
115
* (Mapping set in associated BeanInfo class.)
117
public String getScriptLanguageExpr() { return (scriptLanguageExpr); }
119
* Getter method for "src" tag attribute.
120
* (Mapping set in associated BeanInfo class.)
122
public String getSrcExpr() { return (srcExpr); }
124
* Getter method for "staticJavascript" tag attribute.
125
* (Mapping set in associated BeanInfo class.)
127
public String getStaticJavascriptExpr() { return (staticJavascriptExpr); }
129
* Getter method for "htmlComment" tag attribute.
130
* (Mapping set in associated BeanInfo class.)
132
public String getHtmlCommentExpr() { return (htmlCommentExpr); }
135
* Setter method for "cdata" tag attribute.
136
* (Mapping set in associated BeanInfo class.)
138
public void setCdataExpr(String cdataExpr) { this.cdataExpr = cdataExpr; }
140
* Setter method for "dynamicJavascript" tag attribute.
141
* (Mapping set in associated BeanInfo class.)
143
public void setDynamicJavascriptExpr(String dynamicJavascriptExpr) { this.dynamicJavascriptExpr = dynamicJavascriptExpr; }
145
* Setter method for "formName" tag attribute.
146
* (Mapping set in associated BeanInfo class.)
148
public void setFormNameExpr(String formNameExpr) { this.formNameExpr = formNameExpr; }
150
* Setter method for "method" tag attribute.
151
* (Mapping set in associated BeanInfo class.)
153
public void setMethodExpr(String methodExpr) { this.methodExpr = methodExpr; }
155
* Setter method for "page" tag attribute.
156
* (Mapping set in associated BeanInfo class.)
158
public void setPageExpr(String pageExpr) { this.pageExpr = pageExpr; }
160
* Setter method for "scriptLanguage" tag attribute.
161
* (Mapping set in associated BeanInfo class.)
163
public void setScriptLanguageExpr(String scriptLanguageExpr) { this.scriptLanguageExpr = scriptLanguageExpr; }
165
* Setter method for "src" tag attribute.
166
* (Mapping set in associated BeanInfo class.)
168
public void setSrcExpr(String srcExpr) { this.srcExpr = srcExpr; }
170
* Setter method for "staticJavascript" tag attribute.
171
* (Mapping set in associated BeanInfo class.)
173
public void setStaticJavascriptExpr(String staticJavascriptExpr) { this.staticJavascriptExpr = staticJavascriptExpr; }
175
* Setter method for "htmlComment" tag attribute.
176
* (Mapping set in associated BeanInfo class.)
178
public void setHtmlCommentExpr(String htmlCommentExpr) { this.htmlCommentExpr = htmlCommentExpr; }
181
* Resets attribute values for tag reuse.
183
public void release()
187
setDynamicJavascriptExpr(null);
188
setFormNameExpr(null);
191
setScriptLanguageExpr(null);
193
setStaticJavascriptExpr(null);
194
setHtmlCommentExpr(null);
198
* Process the start tag.
200
* @exception JspException if a JSP exception has occurred
202
public int doStartTag() throws JspException {
203
evaluateExpressions();
204
return (super.doStartTag());
208
* Processes all attribute values which use the JSTL expression evaluation
209
* engine to determine their values.
211
* @exception JspException if a JSP exception has occurred
213
private void evaluateExpressions() throws JspException {
214
String string = null;
215
Integer integer = null;
218
if ((string = EvalHelper.evalString("cdata", getCdataExpr(),
219
this, pageContext)) != null)
222
if ((string = EvalHelper.evalString("dynamicJavascript", getDynamicJavascriptExpr(),
223
this, pageContext)) != null)
224
setDynamicJavascript(string);
226
if ((string = EvalHelper.evalString("formName", getFormNameExpr(),
227
this, pageContext)) != null)
230
if ((string = EvalHelper.evalString("method", getMethodExpr(),
231
this, pageContext)) != null)
234
if ((integer = EvalHelper.evalInteger("page", getPageExpr(),
235
this, pageContext)) != null)
236
setPage(integer.intValue());
238
if ((bool = EvalHelper.evalBoolean("scriptLanguage", getScriptLanguageExpr(),
239
this, pageContext)) != null)
240
setScriptLanguage(bool.booleanValue());
242
if ((string = EvalHelper.evalString("src", getSrcExpr(),
243
this, pageContext)) != null)
246
if ((string = EvalHelper.evalString("staticJavascript", getStaticJavascriptExpr(),
247
this, pageContext)) != null)
248
setStaticJavascript(string);
250
if ((string = EvalHelper.evalString("htmlComment", getHtmlCommentExpr(),
251
this, pageContext)) != null)
252
setHtmlComment(string);