001: /*
002: * $Id: ELFormTag.java 479635 2006-11-27 14:27:18Z pbenedict $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.strutsel.taglib.html;
022:
023: import org.apache.struts.taglib.html.FormTag;
024: import org.apache.strutsel.taglib.utils.EvalHelper;
025:
026: import javax.servlet.jsp.JspException;
027:
028: /**
029: * Custom tag that represents an input form, associated with a bean whose
030: * properties correspond to the various fields of the form. <p> This class is
031: * a subclass of the class <code>org.apache.struts.taglib.html.FormTag</code>
032: * which provides most of the described functionality. This subclass allows
033: * all attribute values to be specified as expressions utilizing the
034: * JavaServer Pages Standard Library expression language.
035: *
036: * @version $Rev: 479635 $
037: */
038: public class ELFormTag extends FormTag {
039: /**
040: * Instance variable mapped to "action" tag attribute. (Mapping set in
041: * associated BeanInfo class.)
042: */
043: private String actionExpr;
044:
045: /**
046: * Instance variable mapped to "dir" tag attribute. (Mapping set in
047: * associated BeanInfo class.)
048: */
049: private String dirExpr;
050:
051: /**
052: * Instance variable mapped to "disabled" tag attribute. (Mapping set in
053: * associated BeanInfo class.)
054: */
055: private String disabledExpr;
056:
057: /**
058: * Instance variable mapped to "enctype" tag attribute. (Mapping set in
059: * associated BeanInfo class.)
060: */
061: private String enctypeExpr;
062:
063: /**
064: * Instance variable mapped to "focus" tag attribute. (Mapping set in
065: * associated BeanInfo class.)
066: */
067: private String focusExpr;
068:
069: /**
070: * Instance variable mapped to "focusIndex" tag attribute. (Mapping set in
071: * associated BeanInfo class.)
072: */
073: private String focusIndexExpr;
074:
075: /**
076: * Instance variable mapped to "lang" tag attribute. (Mapping set in
077: * associated BeanInfo class.)
078: */
079: private String langExpr;
080:
081: /**
082: * Instance variable mapped to "method" tag attribute. (Mapping set in
083: * associated BeanInfo class.)
084: */
085: private String methodExpr;
086:
087: /**
088: * Instance variable mapped to "onreset" tag attribute. (Mapping set in
089: * associated BeanInfo class.)
090: */
091: private String onresetExpr;
092:
093: /**
094: * Instance variable mapped to "onsubmit" tag attribute. (Mapping set in
095: * associated BeanInfo class.)
096: */
097: private String onsubmitExpr;
098:
099: /**
100: * Instance variable mapped to "readonly" tag attribute. (Mapping set in
101: * associated BeanInfo class.)
102: */
103: private String readonlyExpr;
104:
105: /**
106: * Instance variable mapped to "scriptLanguage" tag attribute. (Mapping
107: * set in associated BeanInfo class.)
108: */
109: private String scriptLanguageExpr;
110:
111: /**
112: * Instance variable mapped to "style" tag attribute. (Mapping set in
113: * associated BeanInfo class.)
114: */
115: private String styleExpr;
116:
117: /**
118: * Instance variable mapped to "styleClass" tag attribute. (Mapping set in
119: * associated BeanInfo class.)
120: */
121: private String styleClassExpr;
122:
123: /**
124: * Instance variable mapped to "styleId" tag attribute. (Mapping set in
125: * associated BeanInfo class.)
126: */
127: private String styleIdExpr;
128:
129: /**
130: * Instance variable mapped to "target" tag attribute. (Mapping set in
131: * associated BeanInfo class.)
132: */
133: private String targetExpr;
134:
135: /**
136: * Instance variable mapped to "acceptCharset" tag attribute. (Mapping set
137: * in associated BeanInfo class.)
138: */
139: private String acceptCharsetExpr;
140:
141: /**
142: * Getter method for "action" tag attribute. (Mapping set in associated
143: * BeanInfo class.)
144: */
145: public String getActionExpr() {
146: return (actionExpr);
147: }
148:
149: /**
150: * Getter method for "dir" tag attribute. (Mapping set in associated
151: * BeanInfo class.)
152: */
153: public String getDirExpr() {
154: return (dirExpr);
155: }
156:
157: /**
158: * Getter method for "disabled" tag attribute. (Mapping set in associated
159: * BeanInfo class.)
160: */
161: public String getDisabledExpr() {
162: return (disabledExpr);
163: }
164:
165: /**
166: * Getter method for "enctype" tag attribute. (Mapping set in associated
167: * BeanInfo class.)
168: */
169: public String getEnctypeExpr() {
170: return (enctypeExpr);
171: }
172:
173: /**
174: * Getter method for "focus" tag attribute. (Mapping set in associated
175: * BeanInfo class.)
176: */
177: public String getFocusExpr() {
178: return (focusExpr);
179: }
180:
181: /**
182: * Getter method for "focusIndex" tag attribute. (Mapping set in
183: * associated BeanInfo class.)
184: */
185: public String getFocusIndexExpr() {
186: return (focusIndexExpr);
187: }
188:
189: /**
190: * Getter method for "lang" tag attribute. (Mapping set in associated
191: * BeanInfo class.)
192: */
193: public String getLangExpr() {
194: return (langExpr);
195: }
196:
197: /**
198: * Getter method for "method" tag attribute. (Mapping set in associated
199: * BeanInfo class.)
200: */
201: public String getMethodExpr() {
202: return (methodExpr);
203: }
204:
205: /**
206: * Getter method for "onreset" tag attribute. (Mapping set in associated
207: * BeanInfo class.)
208: */
209: public String getOnresetExpr() {
210: return (onresetExpr);
211: }
212:
213: /**
214: * Getter method for "onsubmit" tag attribute. (Mapping set in associated
215: * BeanInfo class.)
216: */
217: public String getOnsubmitExpr() {
218: return (onsubmitExpr);
219: }
220:
221: /**
222: * Getter method for "readonly" tag attribute. (Mapping set in associated
223: * BeanInfo class.)
224: */
225: public String getReadonlyExpr() {
226: return (readonlyExpr);
227: }
228:
229: /**
230: * Getter method for "scriptLanguage" tag attribute. (Mapping set in
231: * associated BeanInfo class.)
232: */
233: public String getScriptLanguageExpr() {
234: return (scriptLanguageExpr);
235: }
236:
237: /**
238: * Getter method for "style" tag attribute. (Mapping set in associated
239: * BeanInfo class.)
240: */
241: public String getStyleExpr() {
242: return (styleExpr);
243: }
244:
245: /**
246: * Getter method for "styleClass" tag attribute. (Mapping set in
247: * associated BeanInfo class.)
248: */
249: public String getStyleClassExpr() {
250: return (styleClassExpr);
251: }
252:
253: /**
254: * Getter method for "styleId" tag attribute. (Mapping set in associated
255: * BeanInfo class.)
256: */
257: public String getStyleIdExpr() {
258: return (styleIdExpr);
259: }
260:
261: /**
262: * Getter method for "target" tag attribute. (Mapping set in associated
263: * BeanInfo class.)
264: */
265: public String getTargetExpr() {
266: return (targetExpr);
267: }
268:
269: /**
270: * Getter method for "acceptCharset" tag attribute. (Mapping set in
271: * associated BeanInfo class.)
272: */
273: public String getAcceptCharsetExpr() {
274: return (acceptCharsetExpr);
275: }
276:
277: /**
278: * Setter method for "action" tag attribute. (Mapping set in associated
279: * BeanInfo class.)
280: */
281: public void setActionExpr(String actionExpr) {
282: this .actionExpr = actionExpr;
283: }
284:
285: /**
286: * Setter method for "dir" tag attribute. (Mapping set in associated
287: * BeanInfo class.)
288: */
289: public void setDirExpr(String dirExpr) {
290: this .dirExpr = dirExpr;
291: }
292:
293: /**
294: * Setter method for "disabled" tag attribute. (Mapping set in associated
295: * BeanInfo class.)
296: */
297: public void setDisabledExpr(String disabledExpr) {
298: this .disabledExpr = disabledExpr;
299: }
300:
301: /**
302: * Setter method for "enctype" tag attribute. (Mapping set in associated
303: * BeanInfo class.)
304: */
305: public void setEnctypeExpr(String enctypeExpr) {
306: this .enctypeExpr = enctypeExpr;
307: }
308:
309: /**
310: * Setter method for "focus" tag attribute. (Mapping set in associated
311: * BeanInfo class.)
312: */
313: public void setFocusExpr(String focusExpr) {
314: this .focusExpr = focusExpr;
315: }
316:
317: /**
318: * Setter method for "focusIndex" tag attribute. (Mapping set in
319: * associated BeanInfo class.)
320: */
321: public void setFocusIndexExpr(String focusIndexExpr) {
322: this .focusIndexExpr = focusIndexExpr;
323: }
324:
325: /**
326: * Setter method for "lang" tag attribute. (Mapping set in associated
327: * BeanInfo class.)
328: */
329: public void setLangExpr(String langExpr) {
330: this .langExpr = langExpr;
331: }
332:
333: /**
334: * Setter method for "method" tag attribute. (Mapping set in associated
335: * BeanInfo class.)
336: */
337: public void setMethodExpr(String methodExpr) {
338: this .methodExpr = methodExpr;
339: }
340:
341: /**
342: * Setter method for "onreset" tag attribute. (Mapping set in associated
343: * BeanInfo class.)
344: */
345: public void setOnresetExpr(String onresetExpr) {
346: this .onresetExpr = onresetExpr;
347: }
348:
349: /**
350: * Setter method for "onsubmit" tag attribute. (Mapping set in associated
351: * BeanInfo class.)
352: */
353: public void setOnsubmitExpr(String onsubmitExpr) {
354: this .onsubmitExpr = onsubmitExpr;
355: }
356:
357: /**
358: * Setter method for "readonly" tag attribute. (Mapping set in associated
359: * BeanInfo class.)
360: */
361: public void setReadonlyExpr(String readonlyExpr) {
362: this .readonlyExpr = readonlyExpr;
363: }
364:
365: /**
366: * Setter method for "scriptLanguage" tag attribute. (Mapping set in
367: * associated BeanInfo class.)
368: */
369: public void setScriptLanguageExpr(String scriptLanguageExpr) {
370: this .scriptLanguageExpr = scriptLanguageExpr;
371: }
372:
373: /**
374: * Setter method for "style" tag attribute. (Mapping set in associated
375: * BeanInfo class.)
376: */
377: public void setStyleExpr(String styleExpr) {
378: this .styleExpr = styleExpr;
379: }
380:
381: /**
382: * Setter method for "styleClass" tag attribute. (Mapping set in
383: * associated BeanInfo class.)
384: */
385: public void setStyleClassExpr(String styleClassExpr) {
386: this .styleClassExpr = styleClassExpr;
387: }
388:
389: /**
390: * Setter method for "styleId" tag attribute. (Mapping set in associated
391: * BeanInfo class.)
392: */
393: public void setStyleIdExpr(String styleIdExpr) {
394: this .styleIdExpr = styleIdExpr;
395: }
396:
397: /**
398: * Setter method for "target" tag attribute. (Mapping set in associated
399: * BeanInfo class.)
400: */
401: public void setTargetExpr(String targetExpr) {
402: this .targetExpr = targetExpr;
403: }
404:
405: /**
406: * Setter method for "acceptCharset" tag attribute. (Mapping set in
407: * associated BeanInfo class.)
408: */
409: public void setAcceptCharsetExpr(String acceptCharsetExpr) {
410: this .acceptCharsetExpr = acceptCharsetExpr;
411: }
412:
413: /**
414: * Resets attribute values for tag reuse.
415: */
416: public void release() {
417: super .release();
418: setActionExpr(null);
419: setDirExpr(null);
420: setDisabledExpr(null);
421: setEnctypeExpr(null);
422: setFocusExpr(null);
423: setFocusIndexExpr(null);
424: setLangExpr(null);
425: setMethodExpr(null);
426: setOnresetExpr(null);
427: setOnsubmitExpr(null);
428: setReadonlyExpr(null);
429: setScriptLanguageExpr(null);
430: setStyleExpr(null);
431: setStyleClassExpr(null);
432: setStyleIdExpr(null);
433: setTargetExpr(null);
434: setAcceptCharsetExpr(null);
435: }
436:
437: /**
438: * Process the start tag.
439: *
440: * @throws JspException if a JSP exception has occurred
441: */
442: public int doStartTag() throws JspException {
443: evaluateExpressions();
444:
445: return (super .doStartTag());
446: }
447:
448: /**
449: * Processes all attribute values which use the JSTL expression evaluation
450: * engine to determine their values.
451: *
452: * @throws JspException if a JSP exception has occurred
453: */
454: private void evaluateExpressions() throws JspException {
455: String string = null;
456: Boolean bool = null;
457:
458: if ((string = EvalHelper.evalString("action", getActionExpr(),
459: this , pageContext)) != null) {
460: setAction(string);
461: }
462:
463: if ((string = EvalHelper.evalString("dir", getDirExpr(), this ,
464: pageContext)) != null) {
465: setDir(string);
466: }
467:
468: if ((bool = EvalHelper.evalBoolean("disabled",
469: getDisabledExpr(), this , pageContext)) != null) {
470: setDisabled(bool.booleanValue());
471: }
472:
473: if ((string = EvalHelper.evalString("enctype",
474: getEnctypeExpr(), this , pageContext)) != null) {
475: setEnctype(string);
476: }
477:
478: if ((string = EvalHelper.evalString("focus", getFocusExpr(),
479: this , pageContext)) != null) {
480: setFocus(string);
481: }
482:
483: if ((string = EvalHelper.evalString("focusIndex",
484: getFocusIndexExpr(), this , pageContext)) != null) {
485: setFocusIndex(string);
486: }
487:
488: if ((string = EvalHelper.evalString("lang", getLangExpr(),
489: this , pageContext)) != null) {
490: setLang(string);
491: }
492:
493: if ((string = EvalHelper.evalString("method", getMethodExpr(),
494: this , pageContext)) != null) {
495: setMethod(string);
496: }
497:
498: if ((string = EvalHelper.evalString("onreset",
499: getOnresetExpr(), this , pageContext)) != null) {
500: setOnreset(string);
501: }
502:
503: if ((string = EvalHelper.evalString("onsubmit",
504: getOnsubmitExpr(), this , pageContext)) != null) {
505: setOnsubmit(string);
506: }
507:
508: if ((bool = EvalHelper.evalBoolean("readonly",
509: getReadonlyExpr(), this , pageContext)) != null) {
510: setReadonly(bool.booleanValue());
511: }
512:
513: if ((bool = EvalHelper.evalBoolean("scriptLanguage",
514: getScriptLanguageExpr(), this , pageContext)) != null) {
515: setScriptLanguage(bool.booleanValue());
516: }
517:
518: if ((string = EvalHelper.evalString("style", getStyleExpr(),
519: this , pageContext)) != null) {
520: setStyle(string);
521: }
522:
523: if ((string = EvalHelper.evalString("styleClass",
524: getStyleClassExpr(), this , pageContext)) != null) {
525: setStyleClass(string);
526: }
527:
528: if ((string = EvalHelper.evalString("styleId",
529: getStyleIdExpr(), this , pageContext)) != null) {
530: setStyleId(string);
531: }
532:
533: if ((string = EvalHelper.evalString("target", getTargetExpr(),
534: this , pageContext)) != null) {
535: setTarget(string);
536: }
537:
538: if ((string = EvalHelper.evalString("acceptCharset",
539: getAcceptCharsetExpr(), this, pageContext)) != null) {
540: setAcceptCharset(string);
541: }
542: }
543: }
|