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 for button form control tags.
31 *
32 * @author Jose M. Palomar
33 * @version $Revision: 130 $
34 */
35 public class BaseXButtonTag extends BaseControlTag {
36
37
38 /**
39 * Button type.
40 */
41 private String type;
42
43
44 /**
45 * Creates a new <code>BaseXButtonTag</code> object.
46 */
47 public BaseXButtonTag() {
48 }
49
50 /**
51 * Creates a new <code>BaseXButtonTag</code> object for given type.
52 *
53 * @param type String button type.
54 */
55 protected BaseXButtonTag(String type) {
56 this.type = type;
57 }
58
59
60 /**
61 * Process the start tag for this instance.
62 *
63 * @return int EVAL_BODY_INCLUDE.
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(renderButtonStartElement());
71 }
72 catch (IOException ioe) {
73
74 }
75
76 return EVAL_BODY_INCLUDE;
77
78 }
79
80 /**
81 * Process the end tag for this instance.
82 *
83 * @return int EVAL_PAGE.
84 * @throws JspException if somethign goes wrong during processing.
85 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
86 */
87 public int doEndTag() throws JspException {
88
89 try {
90 pageContext.getOut().print(renderButtonEndElement());
91 }
92 catch (IOException ioe) {
93
94 }
95
96 return EVAL_PAGE;
97 }
98
99
100 /**
101 * Renders button start tag.
102 *
103 * @return String a string with rendered button start tag.
104 */
105 public final String renderButtonStartElement() {
106
107 StringBuffer element = new StringBuffer();
108
109 element.append("<button");
110
111 element.append(baseAttributes());
112
113 element.append(" type=\"");
114 element.append(type);
115 element.append("\"");
116
117 element.append(controlName());
118 element.append(controlValue());
119 element.append(controlAttributes());
120 element.append(controlEvents());
121 element.append(intrinsicEvents());
122
123 element.append(">");
124
125 return element.toString();
126
127 }
128
129 /**
130 * Renders button end tag.
131 *
132 * @return String a string with rendered button end tag.
133 */
134 public final String renderButtonEndElement() {
135 return "</button>";
136 }
137
138 }