KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELFormTag.java 160263 2005-04-06 07:44:55Z 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.FormTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Custom tag that represents an input form, associated with a bean whose
27  * properties correspond to the various fields of the form.
28  *<p>
29  * This class is a subclass of the class
30  * <code>org.apache.struts.taglib.html.FormTag</code> which provides most of
31  * the described functionality. This subclass allows all attribute values to
32  * be specified as expressions utilizing the JavaServer Pages Standard Library
33  * expression language.
34  *
35  * @version $Rev: 160263 $
36  */

37 public class ELFormTag extends FormTag {
38
39     /**
40      * Instance variable mapped to "action" tag attribute.
41      * (Mapping set in associated BeanInfo class.)
42      */

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

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

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

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

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

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

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

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

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

88     private String JavaDoc scriptLanguageExpr;
89     /**
90      * Instance variable mapped to "style" tag attribute.
91      * (Mapping set in associated BeanInfo class.)
92      */

93     private String JavaDoc styleExpr;
94     /**
95      * Instance variable mapped to "styleClass" tag attribute.
96      * (Mapping set in associated BeanInfo class.)
97      */

98     private String JavaDoc styleClassExpr;
99     /**
100      * Instance variable mapped to "styleId" tag attribute.
101      * (Mapping set in associated BeanInfo class.)
102      */

103     private String JavaDoc styleIdExpr;
104     /**
105      * Instance variable mapped to "target" tag attribute.
106      * (Mapping set in associated BeanInfo class.)
107      */

108     private String JavaDoc targetExpr;
109     /**
110      * Instance variable mapped to "acceptCharset" tag attribute.
111      * (Mapping set in associated BeanInfo class.)
112      */

113     private String JavaDoc acceptCharsetExpr;
114
115     /**
116      * Getter method for "action" tag attribute.
117      * (Mapping set in associated BeanInfo class.)
118      */

119     public String JavaDoc getActionExpr() { return (actionExpr); }
120     /**
121      * Getter method for "disabled" tag attribute.
122      * (Mapping set in associated BeanInfo class.)
123      */

124     public String JavaDoc getDisabledExpr() { return (disabledExpr); }
125     /**
126      * Getter method for "enctype" tag attribute.
127      * (Mapping set in associated BeanInfo class.)
128      */

129     public String JavaDoc getEnctypeExpr() { return (enctypeExpr); }
130     /**
131      * Getter method for "focus" tag attribute.
132      * (Mapping set in associated BeanInfo class.)
133      */

134     public String JavaDoc getFocusExpr() { return (focusExpr); }
135     /**
136      * Getter method for "focusIndex" tag attribute.
137      * (Mapping set in associated BeanInfo class.)
138      */

139     public String JavaDoc getFocusIndexExpr() { return (focusIndexExpr); }
140     /**
141      * Getter method for "method" tag attribute.
142      * (Mapping set in associated BeanInfo class.)
143      */

144     public String JavaDoc getMethodExpr() { return (methodExpr); }
145     /**
146      * Getter method for "onreset" tag attribute.
147      * (Mapping set in associated BeanInfo class.)
148      */

149     public String JavaDoc getOnresetExpr() { return (onresetExpr); }
150     /**
151      * Getter method for "onsubmit" tag attribute.
152      * (Mapping set in associated BeanInfo class.)
153      */

154     public String JavaDoc getOnsubmitExpr() { return (onsubmitExpr); }
155     /**
156      * Getter method for "readonly" tag attribute.
157      * (Mapping set in associated BeanInfo class.)
158      */

159     public String JavaDoc getReadonlyExpr() { return (readonlyExpr); }
160     /**
161      * Getter method for "scriptLanguage" tag attribute.
162      * (Mapping set in associated BeanInfo class.)
163      */

164     public String JavaDoc getScriptLanguageExpr() { return (scriptLanguageExpr); }
165     /**
166      * Getter method for "style" tag attribute.
167      * (Mapping set in associated BeanInfo class.)
168      */

169     public String JavaDoc getStyleExpr() { return (styleExpr); }
170     /**
171      * Getter method for "styleClass" tag attribute.
172      * (Mapping set in associated BeanInfo class.)
173      */

174     public String JavaDoc getStyleClassExpr() { return (styleClassExpr); }
175     /**
176      * Getter method for "styleId" tag attribute.
177      * (Mapping set in associated BeanInfo class.)
178      */

179     public String JavaDoc getStyleIdExpr() { return (styleIdExpr); }
180     /**
181      * Getter method for "target" tag attribute.
182      * (Mapping set in associated BeanInfo class.)
183      */

184     public String JavaDoc getTargetExpr() { return (targetExpr); }
185     /**
186      * Getter method for "acceptCharset" tag attribute.
187      * (Mapping set in associated BeanInfo class.)
188      */

189     public String JavaDoc getAcceptCharsetExpr() { return (acceptCharsetExpr); }
190
191     /**
192      * Setter method for "action" tag attribute.
193      * (Mapping set in associated BeanInfo class.)
194      */

195     public void setActionExpr(String JavaDoc actionExpr) { this.actionExpr = actionExpr; }
196     /**
197      * Setter method for "disabled" tag attribute.
198      * (Mapping set in associated BeanInfo class.)
199      */

200     public void setDisabledExpr(String JavaDoc disabledExpr) { this.disabledExpr = disabledExpr; }
201     /**
202      * Setter method for "enctype" tag attribute.
203      * (Mapping set in associated BeanInfo class.)
204      */

205     public void setEnctypeExpr(String JavaDoc enctypeExpr) { this.enctypeExpr = enctypeExpr; }
206     /**
207      * Setter method for "focus" tag attribute.
208      * (Mapping set in associated BeanInfo class.)
209      */

210     public void setFocusExpr(String JavaDoc focusExpr) { this.focusExpr = focusExpr; }
211     /**
212      * Setter method for "focusIndex" tag attribute.
213      * (Mapping set in associated BeanInfo class.)
214      */

215     public void setFocusIndexExpr(String JavaDoc focusIndexExpr) { this.focusIndexExpr = focusIndexExpr; }
216     /**
217      * Setter method for "method" tag attribute.
218      * (Mapping set in associated BeanInfo class.)
219      */

220     public void setMethodExpr(String JavaDoc methodExpr) { this.methodExpr = methodExpr; }
221     /**
222      * Setter method for "onreset" tag attribute.
223      * (Mapping set in associated BeanInfo class.)
224      */

225     public void setOnresetExpr(String JavaDoc onresetExpr) { this.onresetExpr = onresetExpr; }
226     /**
227      * Setter method for "onsubmit" tag attribute.
228      * (Mapping set in associated BeanInfo class.)
229      */

230     public void setOnsubmitExpr(String JavaDoc onsubmitExpr) { this.onsubmitExpr = onsubmitExpr; }
231     /**
232      * Setter method for "readonly" tag attribute.
233      * (Mapping set in associated BeanInfo class.)
234      */

235     public void setReadonlyExpr(String JavaDoc readonlyExpr) { this.readonlyExpr = readonlyExpr; }
236     /**
237      * Setter method for "scriptLanguage" tag attribute.
238      * (Mapping set in associated BeanInfo class.)
239      */

240     public void setScriptLanguageExpr(String JavaDoc scriptLanguageExpr) { this.scriptLanguageExpr = scriptLanguageExpr; }
241     /**
242      * Setter method for "style" tag attribute.
243      * (Mapping set in associated BeanInfo class.)
244      */

245     public void setStyleExpr(String JavaDoc styleExpr) { this.styleExpr = styleExpr; }
246     /**
247      * Setter method for "styleClass" tag attribute.
248      * (Mapping set in associated BeanInfo class.)
249      */

250     public void setStyleClassExpr(String JavaDoc styleClassExpr) { this.styleClassExpr = styleClassExpr; }
251     /**
252      * Setter method for "styleId" tag attribute.
253      * (Mapping set in associated BeanInfo class.)
254      */

255     public void setStyleIdExpr(String JavaDoc styleIdExpr) { this.styleIdExpr = styleIdExpr; }
256     /**
257      * Setter method for "target" tag attribute.
258      * (Mapping set in associated BeanInfo class.)
259      */

260     public void setTargetExpr(String JavaDoc targetExpr) { this.targetExpr = targetExpr; }
261     /**
262      * Setter method for "acceptCharset" tag attribute.
263      * (Mapping set in associated BeanInfo class.)
264      */

265     public void setAcceptCharsetExpr(String JavaDoc acceptCharsetExpr) { this.acceptCharsetExpr = acceptCharsetExpr; }
266
267     /**
268      * Resets attribute values for tag reuse.
269      */

270     public void release()
271     {
272         super.release();
273         setActionExpr(null);
274         setDisabledExpr(null);
275         setEnctypeExpr(null);
276         setFocusExpr(null);
277         setFocusIndexExpr(null);
278         setMethodExpr(null);
279         setOnresetExpr(null);
280         setOnsubmitExpr(null);
281         setReadonlyExpr(null);
282         setScriptLanguageExpr(null);
283         setStyleExpr(null);
284         setStyleClassExpr(null);
285         setStyleIdExpr(null);
286         setTargetExpr(null);
287         setAcceptCharsetExpr(null);
288     }
289     
290     /**
291      * Process the start tag.
292      *
293      * @exception JspException if a JSP exception has occurred
294      */

295     public int doStartTag() throws JspException JavaDoc {
296         evaluateExpressions();
297         return(super.doStartTag());
298     }
299
300     /**
301      * Processes all attribute values which use the JSTL expression evaluation
302      * engine to determine their values.
303      *
304      * @exception JspException if a JSP exception has occurred
305      */

306     private void evaluateExpressions() throws JspException JavaDoc {
307         String JavaDoc string = null;
308         Boolean JavaDoc bool = null;
309
310         if ((string = EvalHelper.evalString("action", getActionExpr(),
311                                             this, pageContext)) != null)
312             setAction(string);
313
314         if ((bool = EvalHelper.evalBoolean("disabled", getDisabledExpr(),
315                                            this, pageContext)) != null)
316             setDisabled(bool.booleanValue());
317
318         if ((string = EvalHelper.evalString("enctype", getEnctypeExpr(),
319                                             this, pageContext)) != null)
320             setEnctype(string);
321
322         if ((string = EvalHelper.evalString("focus", getFocusExpr(),
323                                             this, pageContext)) != null)
324             setFocus(string);
325
326         if ((string = EvalHelper.evalString("focusIndex", getFocusIndexExpr(),
327                                             this, pageContext)) != null)
328             setFocusIndex(string);
329
330         if ((string = EvalHelper.evalString("method", getMethodExpr(),
331                                             this, pageContext)) != null)
332             setMethod(string);
333
334         if ((string = EvalHelper.evalString("onreset", getOnresetExpr(),
335                                             this, pageContext)) != null)
336             setOnreset(string);
337
338         if ((string = EvalHelper.evalString("onsubmit", getOnsubmitExpr(),
339                                             this, pageContext)) != null)
340             setOnsubmit(string);
341
342         if ((bool = EvalHelper.evalBoolean("readonly", getReadonlyExpr(),
343                                            this, pageContext)) != null)
344             setReadonly(bool.booleanValue());
345
346        if ((bool = EvalHelper.evalBoolean("scriptLanguage", getScriptLanguageExpr(),
347                                           this, pageContext)) != null)
348            setScriptLanguage(bool.booleanValue());
349
350         if ((string = EvalHelper.evalString("style", getStyleExpr(),
351                                             this, pageContext)) != null)
352             setStyle(string);
353
354         if ((string = EvalHelper.evalString("styleClass", getStyleClassExpr(),
355                                             this, pageContext)) != null)
356             setStyleClass(string);
357
358         if ((string = EvalHelper.evalString("styleId", getStyleIdExpr(),
359                                             this, pageContext)) != null)
360             setStyleId(string);
361
362         if ((string = EvalHelper.evalString("target", getTargetExpr(),
363                                             this, pageContext)) != null)
364             setTarget(string);
365
366         if ((string = EvalHelper.evalString("acceptCharset", getAcceptCharsetExpr(),
367                                             this, pageContext)) != null)
368             setAcceptCharset(string);
369
370     }
371 }
372
Popular Tags