~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELJavascriptValidatorTag.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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 $
 
3
 * $Revision: 1.12 $
 
4
 * $Date: 2004/03/14 07:15:01 $
 
5
 *
 
6
 * Copyright 1999-2004 The Apache Software Foundation.
 
7
 * 
 
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
 
11
 * 
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 * 
 
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.
 
19
 */
 
20
 
 
21
package org.apache.strutsel.taglib.html;
 
22
 
 
23
import org.apache.struts.taglib.html.JavascriptValidatorTag;
 
24
import javax.servlet.jsp.JspException;
 
25
import org.apache.strutsel.taglib.utils.EvalHelper;
 
26
 
 
27
/**
 
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.
 
31
 *<p>
 
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.
 
37
 *
 
38
 * @version $Revision: 1.12 $
 
39
 */
 
40
public class ELJavascriptValidatorTag extends JavascriptValidatorTag {
 
41
 
 
42
    /**
 
43
     * Instance variable mapped to "cdata" tag attribute.
 
44
     * (Mapping set in associated BeanInfo class.)
 
45
     */
 
46
    private String cdataExpr;
 
47
    /**
 
48
     * Instance variable mapped to "dynamicJavascript" tag attribute.
 
49
     * (Mapping set in associated BeanInfo class.)
 
50
     */
 
51
    private String dynamicJavascriptExpr;
 
52
    /**
 
53
     * Instance variable mapped to "formName" tag attribute.
 
54
     * (Mapping set in associated BeanInfo class.)
 
55
     */
 
56
    private String formNameExpr;
 
57
    /**
 
58
     * Instance variable mapped to "method" tag attribute.
 
59
     * (Mapping set in associated BeanInfo class.)
 
60
     */
 
61
    private String methodExpr;
 
62
    /**
 
63
     * Instance variable mapped to "page" tag attribute.
 
64
     * (Mapping set in associated BeanInfo class.)
 
65
     */
 
66
    private String pageExpr;
 
67
    /**
 
68
     * Instance variable mapped to "scriptLanguage" tag attribute.
 
69
     * (Mapping set in associated BeanInfo class.)
 
70
     */
 
71
    private String scriptLanguageExpr;
 
72
    /**
 
73
     * Instance variable mapped to "src" tag attribute.
 
74
     * (Mapping set in associated BeanInfo class.)
 
75
     */
 
76
    private String srcExpr;
 
77
    /**
 
78
     * Instance variable mapped to "staticJavascript" tag attribute.
 
79
     * (Mapping set in associated BeanInfo class.)
 
80
     */
 
81
    private String staticJavascriptExpr;
 
82
    /**
 
83
     * Instance variable mapped to "htmlComment" tag attribute.
 
84
     * (Mapping set in associated BeanInfo class.)
 
85
     */
 
86
    private String htmlCommentExpr;
 
87
 
 
88
    /**
 
89
     * Getter method for "cdata" tag attribute.
 
90
     * (Mapping set in associated BeanInfo class.)
 
91
     */
 
92
    public String getCdataExpr() { return (cdataExpr); }
 
93
    /**
 
94
     * Getter method for "dynamicJavascript" tag attribute.
 
95
     * (Mapping set in associated BeanInfo class.)
 
96
     */
 
97
    public String getDynamicJavascriptExpr() { return (dynamicJavascriptExpr); }
 
98
    /**
 
99
     * Getter method for "formName" tag attribute.
 
100
     * (Mapping set in associated BeanInfo class.)
 
101
     */
 
102
    public String getFormNameExpr() { return (formNameExpr); }
 
103
    /**
 
104
     * Getter method for "method" tag attribute.
 
105
     * (Mapping set in associated BeanInfo class.)
 
106
     */
 
107
    public String getMethodExpr() { return (methodExpr); }
 
108
    /**
 
109
     * Getter method for "page" tag attribute.
 
110
     * (Mapping set in associated BeanInfo class.)
 
111
     */
 
112
    public String getPageExpr() { return (pageExpr); }
 
113
    /**
 
114
     * Getter method for "scriptLanguage" tag attribute.
 
115
     * (Mapping set in associated BeanInfo class.)
 
116
     */
 
117
    public String getScriptLanguageExpr() { return (scriptLanguageExpr); }
 
118
    /**
 
119
     * Getter method for "src" tag attribute.
 
120
     * (Mapping set in associated BeanInfo class.)
 
121
     */
 
122
    public String getSrcExpr() { return (srcExpr); }
 
123
    /**
 
124
     * Getter method for "staticJavascript" tag attribute.
 
125
     * (Mapping set in associated BeanInfo class.)
 
126
     */
 
127
    public String getStaticJavascriptExpr() { return (staticJavascriptExpr); }
 
128
    /**
 
129
     * Getter method for "htmlComment" tag attribute.
 
130
     * (Mapping set in associated BeanInfo class.)
 
131
     */
 
132
    public String getHtmlCommentExpr() { return (htmlCommentExpr); }
 
133
 
 
134
    /**
 
135
     * Setter method for "cdata" tag attribute.
 
136
     * (Mapping set in associated BeanInfo class.)
 
137
     */
 
138
    public void setCdataExpr(String cdataExpr) { this.cdataExpr = cdataExpr; }
 
139
    /**
 
140
     * Setter method for "dynamicJavascript" tag attribute.
 
141
     * (Mapping set in associated BeanInfo class.)
 
142
     */
 
143
    public void setDynamicJavascriptExpr(String dynamicJavascriptExpr) { this.dynamicJavascriptExpr = dynamicJavascriptExpr; }
 
144
    /**
 
145
     * Setter method for "formName" tag attribute.
 
146
     * (Mapping set in associated BeanInfo class.)
 
147
     */
 
148
    public void setFormNameExpr(String formNameExpr) { this.formNameExpr = formNameExpr; }
 
149
    /**
 
150
     * Setter method for "method" tag attribute.
 
151
     * (Mapping set in associated BeanInfo class.)
 
152
     */
 
153
    public void setMethodExpr(String methodExpr) { this.methodExpr = methodExpr; }
 
154
    /**
 
155
     * Setter method for "page" tag attribute.
 
156
     * (Mapping set in associated BeanInfo class.)
 
157
     */
 
158
    public void setPageExpr(String pageExpr) { this.pageExpr = pageExpr; }
 
159
    /**
 
160
     * Setter method for "scriptLanguage" tag attribute.
 
161
     * (Mapping set in associated BeanInfo class.)
 
162
     */
 
163
    public void setScriptLanguageExpr(String scriptLanguageExpr) { this.scriptLanguageExpr = scriptLanguageExpr; }
 
164
    /**
 
165
     * Setter method for "src" tag attribute.
 
166
     * (Mapping set in associated BeanInfo class.)
 
167
     */
 
168
    public void setSrcExpr(String srcExpr) { this.srcExpr = srcExpr; }
 
169
    /**
 
170
     * Setter method for "staticJavascript" tag attribute.
 
171
     * (Mapping set in associated BeanInfo class.)
 
172
     */
 
173
    public void setStaticJavascriptExpr(String staticJavascriptExpr) { this.staticJavascriptExpr = staticJavascriptExpr; }
 
174
    /**
 
175
     * Setter method for "htmlComment" tag attribute.
 
176
     * (Mapping set in associated BeanInfo class.)
 
177
     */
 
178
    public void setHtmlCommentExpr(String htmlCommentExpr) { this.htmlCommentExpr = htmlCommentExpr; }
 
179
 
 
180
    /**
 
181
     * Resets attribute values for tag reuse.
 
182
     */
 
183
    public void release()
 
184
    {
 
185
        super.release();
 
186
        setCdataExpr(null);
 
187
        setDynamicJavascriptExpr(null);
 
188
        setFormNameExpr(null);
 
189
        setMethodExpr(null);
 
190
        setPageExpr(null);
 
191
        setScriptLanguageExpr(null);
 
192
        setSrcExpr(null);
 
193
        setStaticJavascriptExpr(null);
 
194
        setHtmlCommentExpr(null);
 
195
    }
 
196
 
 
197
    /**
 
198
     * Process the start tag.
 
199
     *
 
200
     * @exception JspException if a JSP exception has occurred
 
201
     */
 
202
    public int doStartTag() throws JspException {
 
203
        evaluateExpressions();
 
204
        return (super.doStartTag());
 
205
    }
 
206
    
 
207
    /**
 
208
     * Processes all attribute values which use the JSTL expression evaluation
 
209
     * engine to determine their values.
 
210
     *
 
211
     * @exception JspException if a JSP exception has occurred
 
212
     */
 
213
    private void evaluateExpressions() throws JspException {
 
214
        String  string  = null;
 
215
        Integer integer = null;
 
216
        Boolean bool    = null;
 
217
 
 
218
        if ((string = EvalHelper.evalString("cdata", getCdataExpr(),
 
219
                                            this, pageContext)) != null)
 
220
            setCdata(string);
 
221
 
 
222
        if ((string = EvalHelper.evalString("dynamicJavascript", getDynamicJavascriptExpr(),
 
223
                                            this, pageContext)) != null)
 
224
            setDynamicJavascript(string);
 
225
 
 
226
        if ((string = EvalHelper.evalString("formName", getFormNameExpr(),
 
227
                                            this, pageContext)) != null)
 
228
            setFormName(string);
 
229
 
 
230
        if ((string = EvalHelper.evalString("method", getMethodExpr(),
 
231
                                            this, pageContext)) != null)
 
232
            setMethod(string);
 
233
 
 
234
        if ((integer = EvalHelper.evalInteger("page", getPageExpr(),
 
235
                                              this, pageContext)) != null)
 
236
            setPage(integer.intValue());
 
237
 
 
238
        if ((bool = EvalHelper.evalBoolean("scriptLanguage", getScriptLanguageExpr(),
 
239
                                           this, pageContext)) != null)
 
240
            setScriptLanguage(bool.booleanValue());
 
241
 
 
242
        if ((string = EvalHelper.evalString("src", getSrcExpr(),
 
243
                                            this, pageContext)) != null)
 
244
            setSrc(string);
 
245
 
 
246
        if ((string = EvalHelper.evalString("staticJavascript", getStaticJavascriptExpr(),
 
247
                                            this, pageContext)) != null)
 
248
            setStaticJavascript(string);
 
249
 
 
250
        if ((string = EvalHelper.evalString("htmlComment", getHtmlCommentExpr(),
 
251
                                            this, pageContext)) != null)
 
252
            setHtmlComment(string);
 
253
    }
 
254
}