1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts.taglib.html;
22
23 import org.apache.struts.taglib.TagUtils;
24
25 import javax.servlet.jsp.JspException;
26
27
28
29
30
31
32
33 public abstract class BaseFieldTag extends BaseInputTag {
34
35
36
37
38
39
40
41
42 protected String accept = null;
43
44
45
46
47 protected boolean redisplay = true;
48
49
50
51
52
53 protected String type = null;
54
55 public String getAccept() {
56 return (this.accept);
57 }
58
59 public void setAccept(String accept) {
60 this.accept = accept;
61 }
62
63 public boolean getRedisplay() {
64 return (this.redisplay);
65 }
66
67 public void setRedisplay(boolean redisplay) {
68 this.redisplay = redisplay;
69 }
70
71
72
73
74
75
76
77
78
79 public int doStartTag() throws JspException {
80 TagUtils.getInstance().write(this.pageContext, this.renderInputElement());
81
82 return (EVAL_BODY_TAG);
83 }
84
85
86
87
88
89
90
91 protected String renderInputElement()
92 throws JspException {
93 StringBuffer results = new StringBuffer("<input");
94
95 prepareAttribute(results, "type", this.type);
96 prepareAttribute(results, "name", prepareName());
97 prepareAttribute(results, "accesskey", getAccesskey());
98 prepareAttribute(results, "accept", getAccept());
99 prepareAttribute(results, "maxlength", getMaxlength());
100 prepareAttribute(results, "size", getCols());
101 prepareAttribute(results, "tabindex", getTabindex());
102 prepareValue(results);
103 results.append(this.prepareEventHandlers());
104 results.append(this.prepareStyles());
105 if (!isXhtml()) {
106 prepareAttribute(results, "autocomplete", getAutocomplete());
107 }
108 prepareOtherAttributes(results);
109 results.append(this.getElementClose());
110
111 return results.toString();
112 }
113
114
115
116
117
118
119 protected void prepareValue(StringBuffer results)
120 throws JspException {
121 results.append(" value=\"");
122
123 if (value != null) {
124 results.append(this.formatValue(value));
125 } else if (redisplay || !"password".equals(type)) {
126 Object value =
127 TagUtils.getInstance().lookup(pageContext, name, property, null);
128
129 results.append(this.formatValue(value));
130 }
131
132 results.append('"');
133 }
134
135
136
137
138
139
140
141
142
143
144 protected String formatValue(Object value)
145 throws JspException {
146 if (value == null) {
147 return "";
148 }
149
150 return TagUtils.getInstance().filter(value.toString());
151 }
152
153
154
155
156 public void release() {
157 super.release();
158 accept = null;
159 name = Constants.BEAN_KEY;
160 redisplay = true;
161 }
162 }