1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.taglib.form;
24
25 /**
26 * Implementation of input type text form control tag. Also base implementation for
27 * <code>PasswordTag</code>.
28 *
29 * @author Jose M. Palomar
30 * @version $Revision: 130 $
31 */
32 public class TextTag extends InputTag {
33
34
35 /**
36 * <code>size</code> attribute.
37 */
38 private String size;
39
40 /**
41 * <code>maxlength</code> attribute.
42 */
43 private String maxlength;
44
45
46 /**
47 * Creates a new <code>TextTag</code> object.
48 */
49 public TextTag() {
50 super("text");
51 }
52
53 /**
54 * Creates a new <code>TextTag</code> object of given input type.
55 *
56 * @param type String input type.
57 */
58 public TextTag(String type) {
59 super(type);
60 }
61
62
63 /**
64 * Renders a string with values of input attributes.<br>
65 * Input attributes for text are <code>size</code> and <code>maxlength</code>.
66 *
67 * @return String a string with values of input attributes.
68 */
69 public final String inputAttributes() {
70
71 StringBuffer atts = new StringBuffer();
72
73 if (size != null) {
74 atts.append(" size=\"");
75 atts.append(size);
76 atts.append("\"");
77 }
78
79 if (maxlength != null) {
80 atts.append(" maxlength=\"");
81 atts.append(maxlength);
82 atts.append("\"");
83 }
84
85 return atts.toString();
86
87 }
88
89
90 /**
91 * Sets <code>size</code> attribute value.
92 *
93 * @param size String <code>size</code> attribute value.
94 */
95 public final void setSize(String size) {
96 this.size = size;
97 }
98
99 /**
100 * Sets <code>maxlength</code> attribute value.
101 *
102 * @param maxlength String <code>maxlength</code> attribute value.
103 */
104 public final void setMaxlength(String maxlength) {
105 this.maxlength = maxlength;
106 }
107
108 /**
109 * Called on a Tag handler to release state.
110 *
111 * @see javax.servlet.jsp.tagext.Tag#release()
112 */
113 public void release() {
114
115 super.release();
116
117 this.size = null;
118 this.maxlength = null;
119
120 }
121
122 }