View Javadoc

1   /*
2    * $Id: ELFormTag.java 376779 2006-02-10 18:08:58Z husted $
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  package org.apache.strutsel.taglib.html;
19  
20  import org.apache.struts.taglib.html.FormTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
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. <p> This class is
28   * a subclass of the class <code>org.apache.struts.taglib.html.FormTag</code>
29   * which provides most of the described functionality.  This subclass allows
30   * all attribute values to be specified as expressions utilizing the
31   * JavaServer Pages Standard Library expression language.
32   *
33   * @version $Rev: 376779 $
34   */
35  public class ELFormTag extends FormTag {
36      /***
37       * Instance variable mapped to "action" tag attribute. (Mapping set in
38       * associated BeanInfo class.)
39       */
40      private String actionExpr;
41  
42      /***
43       * Instance variable mapped to "disabled" tag attribute. (Mapping set in
44       * associated BeanInfo class.)
45       */
46      private String disabledExpr;
47  
48      /***
49       * Instance variable mapped to "enctype" tag attribute. (Mapping set in
50       * associated BeanInfo class.)
51       */
52      private String enctypeExpr;
53  
54      /***
55       * Instance variable mapped to "focus" tag attribute. (Mapping set in
56       * associated BeanInfo class.)
57       */
58      private String focusExpr;
59  
60      /***
61       * Instance variable mapped to "focusIndex" tag attribute. (Mapping set in
62       * associated BeanInfo class.)
63       */
64      private String focusIndexExpr;
65  
66      /***
67       * Instance variable mapped to "method" tag attribute. (Mapping set in
68       * associated BeanInfo class.)
69       */
70      private String methodExpr;
71  
72      /***
73       * Instance variable mapped to "onreset" tag attribute. (Mapping set in
74       * associated BeanInfo class.)
75       */
76      private String onresetExpr;
77  
78      /***
79       * Instance variable mapped to "onsubmit" tag attribute. (Mapping set in
80       * associated BeanInfo class.)
81       */
82      private String onsubmitExpr;
83  
84      /***
85       * Instance variable mapped to "readonly" tag attribute. (Mapping set in
86       * associated BeanInfo class.)
87       */
88      private String readonlyExpr;
89  
90      /***
91       * Instance variable mapped to "scriptLanguage" tag attribute. (Mapping
92       * set in associated BeanInfo class.)
93       */
94      private String scriptLanguageExpr;
95  
96      /***
97       * Instance variable mapped to "style" tag attribute. (Mapping set in
98       * associated BeanInfo class.)
99       */
100     private String styleExpr;
101 
102     /***
103      * Instance variable mapped to "styleClass" tag attribute. (Mapping set in
104      * associated BeanInfo class.)
105      */
106     private String styleClassExpr;
107 
108     /***
109      * Instance variable mapped to "styleId" tag attribute. (Mapping set in
110      * associated BeanInfo class.)
111      */
112     private String styleIdExpr;
113 
114     /***
115      * Instance variable mapped to "target" tag attribute. (Mapping set in
116      * associated BeanInfo class.)
117      */
118     private String targetExpr;
119 
120     /***
121      * Instance variable mapped to "acceptCharset" tag attribute. (Mapping set
122      * in associated BeanInfo class.)
123      */
124     private String acceptCharsetExpr;
125 
126     /***
127      * Getter method for "action" tag attribute. (Mapping set in associated
128      * BeanInfo class.)
129      */
130     public String getActionExpr() {
131         return (actionExpr);
132     }
133 
134     /***
135      * Getter method for "disabled" tag attribute. (Mapping set in associated
136      * BeanInfo class.)
137      */
138     public String getDisabledExpr() {
139         return (disabledExpr);
140     }
141 
142     /***
143      * Getter method for "enctype" tag attribute. (Mapping set in associated
144      * BeanInfo class.)
145      */
146     public String getEnctypeExpr() {
147         return (enctypeExpr);
148     }
149 
150     /***
151      * Getter method for "focus" tag attribute. (Mapping set in associated
152      * BeanInfo class.)
153      */
154     public String getFocusExpr() {
155         return (focusExpr);
156     }
157 
158     /***
159      * Getter method for "focusIndex" tag attribute. (Mapping set in
160      * associated BeanInfo class.)
161      */
162     public String getFocusIndexExpr() {
163         return (focusIndexExpr);
164     }
165 
166     /***
167      * Getter method for "method" tag attribute. (Mapping set in associated
168      * BeanInfo class.)
169      */
170     public String getMethodExpr() {
171         return (methodExpr);
172     }
173 
174     /***
175      * Getter method for "onreset" tag attribute. (Mapping set in associated
176      * BeanInfo class.)
177      */
178     public String getOnresetExpr() {
179         return (onresetExpr);
180     }
181 
182     /***
183      * Getter method for "onsubmit" tag attribute. (Mapping set in associated
184      * BeanInfo class.)
185      */
186     public String getOnsubmitExpr() {
187         return (onsubmitExpr);
188     }
189 
190     /***
191      * Getter method for "readonly" tag attribute. (Mapping set in associated
192      * BeanInfo class.)
193      */
194     public String getReadonlyExpr() {
195         return (readonlyExpr);
196     }
197 
198     /***
199      * Getter method for "scriptLanguage" tag attribute. (Mapping set in
200      * associated BeanInfo class.)
201      */
202     public String getScriptLanguageExpr() {
203         return (scriptLanguageExpr);
204     }
205 
206     /***
207      * Getter method for "style" tag attribute. (Mapping set in associated
208      * BeanInfo class.)
209      */
210     public String getStyleExpr() {
211         return (styleExpr);
212     }
213 
214     /***
215      * Getter method for "styleClass" tag attribute. (Mapping set in
216      * associated BeanInfo class.)
217      */
218     public String getStyleClassExpr() {
219         return (styleClassExpr);
220     }
221 
222     /***
223      * Getter method for "styleId" tag attribute. (Mapping set in associated
224      * BeanInfo class.)
225      */
226     public String getStyleIdExpr() {
227         return (styleIdExpr);
228     }
229 
230     /***
231      * Getter method for "target" tag attribute. (Mapping set in associated
232      * BeanInfo class.)
233      */
234     public String getTargetExpr() {
235         return (targetExpr);
236     }
237 
238     /***
239      * Getter method for "acceptCharset" tag attribute. (Mapping set in
240      * associated BeanInfo class.)
241      */
242     public String getAcceptCharsetExpr() {
243         return (acceptCharsetExpr);
244     }
245 
246     /***
247      * Setter method for "action" tag attribute. (Mapping set in associated
248      * BeanInfo class.)
249      */
250     public void setActionExpr(String actionExpr) {
251         this.actionExpr = actionExpr;
252     }
253 
254     /***
255      * Setter method for "disabled" tag attribute. (Mapping set in associated
256      * BeanInfo class.)
257      */
258     public void setDisabledExpr(String disabledExpr) {
259         this.disabledExpr = disabledExpr;
260     }
261 
262     /***
263      * Setter method for "enctype" tag attribute. (Mapping set in associated
264      * BeanInfo class.)
265      */
266     public void setEnctypeExpr(String enctypeExpr) {
267         this.enctypeExpr = enctypeExpr;
268     }
269 
270     /***
271      * Setter method for "focus" tag attribute. (Mapping set in associated
272      * BeanInfo class.)
273      */
274     public void setFocusExpr(String focusExpr) {
275         this.focusExpr = focusExpr;
276     }
277 
278     /***
279      * Setter method for "focusIndex" tag attribute. (Mapping set in
280      * associated BeanInfo class.)
281      */
282     public void setFocusIndexExpr(String focusIndexExpr) {
283         this.focusIndexExpr = focusIndexExpr;
284     }
285 
286     /***
287      * Setter method for "method" tag attribute. (Mapping set in associated
288      * BeanInfo class.)
289      */
290     public void setMethodExpr(String methodExpr) {
291         this.methodExpr = methodExpr;
292     }
293 
294     /***
295      * Setter method for "onreset" tag attribute. (Mapping set in associated
296      * BeanInfo class.)
297      */
298     public void setOnresetExpr(String onresetExpr) {
299         this.onresetExpr = onresetExpr;
300     }
301 
302     /***
303      * Setter method for "onsubmit" tag attribute. (Mapping set in associated
304      * BeanInfo class.)
305      */
306     public void setOnsubmitExpr(String onsubmitExpr) {
307         this.onsubmitExpr = onsubmitExpr;
308     }
309 
310     /***
311      * Setter method for "readonly" tag attribute. (Mapping set in associated
312      * BeanInfo class.)
313      */
314     public void setReadonlyExpr(String readonlyExpr) {
315         this.readonlyExpr = readonlyExpr;
316     }
317 
318     /***
319      * Setter method for "scriptLanguage" tag attribute. (Mapping set in
320      * associated BeanInfo class.)
321      */
322     public void setScriptLanguageExpr(String scriptLanguageExpr) {
323         this.scriptLanguageExpr = scriptLanguageExpr;
324     }
325 
326     /***
327      * Setter method for "style" tag attribute. (Mapping set in associated
328      * BeanInfo class.)
329      */
330     public void setStyleExpr(String styleExpr) {
331         this.styleExpr = styleExpr;
332     }
333 
334     /***
335      * Setter method for "styleClass" tag attribute. (Mapping set in
336      * associated BeanInfo class.)
337      */
338     public void setStyleClassExpr(String styleClassExpr) {
339         this.styleClassExpr = styleClassExpr;
340     }
341 
342     /***
343      * Setter method for "styleId" tag attribute. (Mapping set in associated
344      * BeanInfo class.)
345      */
346     public void setStyleIdExpr(String styleIdExpr) {
347         this.styleIdExpr = styleIdExpr;
348     }
349 
350     /***
351      * Setter method for "target" tag attribute. (Mapping set in associated
352      * BeanInfo class.)
353      */
354     public void setTargetExpr(String targetExpr) {
355         this.targetExpr = targetExpr;
356     }
357 
358     /***
359      * Setter method for "acceptCharset" tag attribute. (Mapping set in
360      * associated BeanInfo class.)
361      */
362     public void setAcceptCharsetExpr(String acceptCharsetExpr) {
363         this.acceptCharsetExpr = acceptCharsetExpr;
364     }
365 
366     /***
367      * Resets attribute values for tag reuse.
368      */
369     public void release() {
370         super.release();
371         setActionExpr(null);
372         setDisabledExpr(null);
373         setEnctypeExpr(null);
374         setFocusExpr(null);
375         setFocusIndexExpr(null);
376         setMethodExpr(null);
377         setOnresetExpr(null);
378         setOnsubmitExpr(null);
379         setReadonlyExpr(null);
380         setScriptLanguageExpr(null);
381         setStyleExpr(null);
382         setStyleClassExpr(null);
383         setStyleIdExpr(null);
384         setTargetExpr(null);
385         setAcceptCharsetExpr(null);
386     }
387 
388     /***
389      * Process the start tag.
390      *
391      * @throws JspException if a JSP exception has occurred
392      */
393     public int doStartTag() throws JspException {
394         evaluateExpressions();
395 
396         return (super.doStartTag());
397     }
398 
399     /***
400      * Processes all attribute values which use the JSTL expression evaluation
401      * engine to determine their values.
402      *
403      * @throws JspException if a JSP exception has occurred
404      */
405     private void evaluateExpressions()
406         throws JspException {
407         String string = null;
408         Boolean bool = null;
409 
410         if ((string =
411                 EvalHelper.evalString("action", getActionExpr(), this,
412                     pageContext)) != null) {
413             setAction(string);
414         }
415 
416         if ((bool =
417                 EvalHelper.evalBoolean("disabled", getDisabledExpr(), this,
418                     pageContext)) != null) {
419             setDisabled(bool.booleanValue());
420         }
421 
422         if ((string =
423                 EvalHelper.evalString("enctype", getEnctypeExpr(), this,
424                     pageContext)) != null) {
425             setEnctype(string);
426         }
427 
428         if ((string =
429                 EvalHelper.evalString("focus", getFocusExpr(), this, pageContext)) != null) {
430             setFocus(string);
431         }
432 
433         if ((string =
434                 EvalHelper.evalString("focusIndex", getFocusIndexExpr(), this,
435                     pageContext)) != null) {
436             setFocusIndex(string);
437         }
438 
439         if ((string =
440                 EvalHelper.evalString("method", getMethodExpr(), this,
441                     pageContext)) != null) {
442             setMethod(string);
443         }
444 
445         if ((string =
446                 EvalHelper.evalString("onreset", getOnresetExpr(), this,
447                     pageContext)) != null) {
448             setOnreset(string);
449         }
450 
451         if ((string =
452                 EvalHelper.evalString("onsubmit", getOnsubmitExpr(), this,
453                     pageContext)) != null) {
454             setOnsubmit(string);
455         }
456 
457         if ((bool =
458                 EvalHelper.evalBoolean("readonly", getReadonlyExpr(), this,
459                     pageContext)) != null) {
460             setReadonly(bool.booleanValue());
461         }
462 
463         if ((bool =
464                 EvalHelper.evalBoolean("scriptLanguage",
465                     getScriptLanguageExpr(), this, pageContext)) != null) {
466             setScriptLanguage(bool.booleanValue());
467         }
468 
469         if ((string =
470                 EvalHelper.evalString("style", getStyleExpr(), this, pageContext)) != null) {
471             setStyle(string);
472         }
473 
474         if ((string =
475                 EvalHelper.evalString("styleClass", getStyleClassExpr(), this,
476                     pageContext)) != null) {
477             setStyleClass(string);
478         }
479 
480         if ((string =
481                 EvalHelper.evalString("styleId", getStyleIdExpr(), this,
482                     pageContext)) != null) {
483             setStyleId(string);
484         }
485 
486         if ((string =
487                 EvalHelper.evalString("target", getTargetExpr(), this,
488                     pageContext)) != null) {
489             setTarget(string);
490         }
491 
492         if ((string =
493                 EvalHelper.evalString("acceptCharset", getAcceptCharsetExpr(),
494                     this, pageContext)) != null) {
495             setAcceptCharset(string);
496         }
497     }
498 }