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 import java.io.IOException;
26
27 import javax.servlet.jsp.JspException;
28
29 /**
30 * Base implementation of input form control tags.
31 *
32 * @author Jose M. Palomar
33 * @version $Revision: 130 $
34 */
35 public abstract class InputTag extends BaseControlTag {
36
37
38 /**
39 * Input type.
40 */
41 private String type;
42
43
44 /**
45 * Creates a new <code>InputTag</code> object.
46 */
47 public InputTag() {
48 }
49
50 /**
51 * Creates a new <code>InputTag</code> object of given type.
52 *
53 * @param type String input type.
54 */
55 protected InputTag(String type) {
56 this.type = type;
57 }
58
59
60 /**
61 * Process the start tag for this instance.
62 *
63 * @return int SKIP^_BODY.
64 * @throws JspException if somethign goes wrong during processing.
65 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
66 */
67 public int doStartTag() throws JspException {
68
69 try {
70 pageContext.getOut().print(renderInputElement());
71 }
72 catch (IOException ioe) {
73
74 }
75
76 return SKIP_BODY;
77
78 }
79
80
81 /**
82 * Renders input tag.
83 *
84 * @return String a string with rendered input tag.
85 */
86 public final String renderInputElement() {
87
88 StringBuffer element = new StringBuffer();
89
90 element.append("<input");
91
92 element.append(baseAttributes());
93
94 element.append(" type=\"");
95 element.append(type);
96 element.append("\"");
97
98 element.append(controlName());
99 element.append(controlValue());
100 element.append(inputAttributes());
101 element.append(controlAttributes());
102 element.append(controlEvents());
103 element.append(intrinsicEvents());
104
105 element.append(">");
106
107 return element.toString();
108
109 }
110
111 /**
112 * Renders a string with values of input attributes.
113 *
114 * @return String an empty string.
115 */
116 public String inputAttributes() {
117 return "";
118 }
119
120 }