2
* $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v 1.18 2004/03/14 06:23:46 sraeburn Exp $
4
* $Date: 2004/03/14 06:23:46 $
6
* Copyright 1999-2004 The Apache Software Foundation.
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
21
package org.apache.struts.taglib.html;
23
import javax.servlet.jsp.JspException;
25
import org.apache.struts.taglib.TagUtils;
28
* Renders an HTML BUTTON tag within the Struts framework.
30
* @version $Revision: 1.18 $ $Date: 2004/03/14 06:23:46 $
32
public class ButtonTag extends BaseHandlerTag {
35
// ----------------------------------------------------- Instance Variables
38
* The property name of the generated button.
40
protected String property = null;
44
* The body content of this tag (if any).
46
protected String text = null;
50
* The value of the button label.
52
protected String value = null;
55
// ------------------------------------------------------------- Properties
59
* Return the property name.
61
public String getProperty() {
66
* Set the property name.
68
* @param property The property name
70
public void setProperty(String property) {
71
this.property = property;
76
* Return the label value.
78
public String getValue() {
84
* Set the label value.
85
* @param value The label value
87
public void setValue(String value) {
92
// --------------------------------------------------------- Public Methods
96
* Process the start of this tag.
97
* @exception JspException if a JSP exception has occurred
99
public int doStartTag() throws JspException {
101
// Do nothing until doEndTag() is called
103
return (EVAL_BODY_TAG);
109
* Save the associated label from the body content (if any).
110
* @exception JspException if a JSP exception has occurred
112
public int doAfterBody() throws JspException {
114
if (bodyContent != null) {
115
String value = bodyContent.getString().trim();
116
if (value.length() > 0)
125
* Process the end of this tag.
127
* Support for indexed property since Struts 1.1
128
* @exception JspException if a JSP exception has occurred
130
public int doEndTag() throws JspException {
132
// Acquire the label value we will be generating
133
String label = value;
134
if ((label == null) && (text != null))
136
if ((label == null) || (label.trim().length() < 1))
139
// Generate an HTML element
140
StringBuffer results = new StringBuffer();
141
results.append("<input type=\"button\"");
142
if (property != null) {
143
results.append(" name=\"");
144
results.append(property);
145
// * @since Struts 1.1
147
prepareIndex( results, null );
148
results.append("\"");
150
if (accesskey != null) {
151
results.append(" accesskey=\"");
152
results.append(accesskey);
153
results.append("\"");
155
if (tabindex != null) {
156
results.append(" tabindex=\"");
157
results.append(tabindex);
158
results.append("\"");
160
results.append(" value=\"");
161
results.append(label);
162
results.append("\"");
163
results.append(prepareEventHandlers());
164
results.append(prepareStyles());
165
results.append(getElementClose());
167
// Render this element to our writer
168
TagUtils.getInstance().write(pageContext, results.toString());
170
// Evaluate the remainder of this page
177
* Release any acquired resources.
179
public void release() {