2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.validator.faces;
19
20 import javax.servlet.jsp.tagext.TagSupport;
21 import javax.servlet.jsp.tagext.Tag;
22 import javax.servlet.jsp.JspException;
23
24 /***
25 * The tag class for the <code>s:validatorVar</code> tag, used to specify
26 * parameters to specific validators of Commons Validator.
27 * <p/>
28 * $Id: ValidatorVarTag.java 465067 2006-10-17 21:45:17Z rahul $
29 */
30 public class ValidatorVarTag extends TagSupport {
31
32 /***
33 * Serial version UID.
34 */
35 private static final long serialVersionUID = -7534191231970388638L;
36
37
38 /***
39 * The parent validator tag.
40 */
41 private ValidatorTag commonsValidatorTag = null;
42
43
44 /***
45 * The name of the var to pass to the validator.
46 */
47 private String name;
48
49
50 /***
51 * The value of the var to pass to the validator.
52 */
53 private String value;
54
55
56 /***
57 * Keeps track of the <s:commonsValidator> tag.
58 * <p/>
59 *
60 * @param tag the parent tag of this tag instance.
61 */
62 public void setParent(Tag tag) {
63 super.setParent(tag);
64 if (tag instanceof ValidatorTag) {
65 commonsValidatorTag = (ValidatorTag) tag;
66 } else {
67 throw new IllegalStateException(
68 "This tag must be used inside a <s:commonsValidator> tag");
69 }
70 }
71
72
73 /***
74 * Pass the validation parameter to the commonsValidatorTag that immediately
75 * surrounds this tag.
76 *
77 * @exception JspException if a JSP processing error occurs
78 * @return Request to evaluate the page
79 */
80 public int doEndTag() throws JspException {
81 commonsValidatorTag.addParam(name, value);
82 return EVAL_PAGE;
83 }
84
85
86 //**************************************************************** Accessors
87
88
89 /**
90 * The var name.
91 *
92 * @param name The variable name
93 */
94 public void setName(String name) {
95 this.name = name;
96 }
97
98
99 /***
100 * The var value.
101 *
102 * @param value The variable value
103 */
104 public void setValue(String value) {
105 this.value = value;
106 }
107
108
109 }