KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > tags > form > AbstractHtmlInputElementTag


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.web.servlet.tags.form;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20
21 /**
22  * Base class for databinding-aware JSP tags that render HTML form input element.
23  *
24  * <p>Provides a set of properties corresponding to the set of HTML attributes
25  * that are common across form input elements.
26  *
27  * @author Rob Harrop
28  * @since 2.0
29  */

30 public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag {
31
32     /**
33      * The name of the '<code>onfocus</code>' attribute.
34      */

35     public static final String JavaDoc ONFOCUS_ATTRIBUTE = "onfocus";
36
37     /**
38      * The name of the '<code>onblur</code>' attribute.
39      */

40     public static final String JavaDoc ONBLUR_ATTRIBUTE = "onblur";
41
42     /**
43      * The name of the '<code>onchange</code>' attribute.
44      */

45     public static final String JavaDoc ONCHANGE_ATTRIBUTE = "onchange";
46
47     /**
48      * The name of the '<code>accesskey</code>' attribute.
49      */

50     public static final String JavaDoc ACCESSKEY_ATTRIBUTE = "accesskey";
51
52     /**
53      * The name of the '<code>disabled</code>' attribute.
54      */

55     public static final String JavaDoc DISABLED_ATTRIBUTE = "disabled";
56
57
58     /**
59      * The value of the '<code>onfocus</code>' attribute.
60      */

61     private String JavaDoc onfocus;
62
63     /**
64      * The value of the '<code>onblur</code>' attribute.
65      */

66     private String JavaDoc onblur;
67
68     /**
69      * The value of the '<code>onchange</code>' attribute.
70      */

71     private String JavaDoc onchange;
72
73     /**
74      * The value of the '<code>accesskey</code>' attribute.
75      */

76     private String JavaDoc accesskey;
77
78     /**
79      * The value of the '<code>disabled</code>' attribute.
80      */

81     protected String JavaDoc disabled;
82
83
84     /**
85      * Sets the value of the '<code>onfocus</code>' attribute.
86      * May be a runtime expression.
87      */

88     public void setOnfocus(String JavaDoc onfocus) {
89         this.onfocus = onfocus;
90     }
91
92     /**
93      * Gets the value of the '<code>onfocus</code>' attribute.
94      * May be a runtime expression.
95      */

96     protected String JavaDoc getOnfocus() {
97         return this.onfocus;
98     }
99
100     /**
101      * Sets the value of the '<code>onblur</code>' attribute.
102      * May be a runtime expression.
103      */

104     public void setOnblur(String JavaDoc onblur) {
105         this.onblur = onblur;
106     }
107
108
109     /**
110      * Gets the value of the '<code>onblur</code>' attribute.
111      * May be a runtime expression.
112      */

113     protected String JavaDoc getOnblur() {
114         return this.onblur;
115     }
116
117     /**
118      * Sets the value of the '<code>onchange</code>' attribute.
119      * May be a runtime expression.
120      */

121     public void setOnchange(String JavaDoc onchange) {
122         this.onchange = onchange;
123     }
124
125     /**
126      * Gets the value of the '<code>onchange</code>' attribute.
127      * May be a runtime expression.
128      */

129     protected String JavaDoc getOnchange() {
130         return this.onchange;
131     }
132
133     /**
134      * Sets the value of the '<code>accesskey</code>' attribute.
135      * May be a runtime expression.
136      */

137     public void setAccesskey(String JavaDoc accesskey) {
138         this.accesskey = accesskey;
139     }
140
141     /**
142      * Gets the value of the '<code>accesskey</code>' attribute.
143      * May be a runtime expression.
144      */

145     protected String JavaDoc getAccesskey() {
146         return this.accesskey;
147     }
148
149     /**
150      * Sets the value of the '<code>disabled</code>' attribute.
151      * May be a runtime expression.
152      */

153     public void setDisabled(String JavaDoc disabled) {
154         this.disabled = disabled;
155     }
156
157     /**
158      * Gets the value of the '<code>disabled</code>' attribute.
159      * May be a runtime expression.
160      */

161     protected String JavaDoc getDisabled() {
162         return disabled;
163     }
164
165
166     /**
167      * Writes the default attributes configured via this base class to the supplied {@link TagWriter}.
168      * Subclasses should call this when they want the base attribute set to be written to the output.
169      */

170     protected void writeDefaultAttributes(TagWriter tagWriter) throws JspException JavaDoc {
171         super.writeDefaultAttributes(tagWriter);
172         writeOptionalAttribute(tagWriter, ONFOCUS_ATTRIBUTE, getOnfocus());
173         writeOptionalAttribute(tagWriter, ONBLUR_ATTRIBUTE, getOnblur());
174         writeOptionalAttribute(tagWriter, ONCHANGE_ATTRIBUTE, getOnchange());
175         writeOptionalAttribute(tagWriter, ACCESSKEY_ATTRIBUTE, getAccesskey());
176         if(isDisabled()) {
177             tagWriter.writeAttribute(DISABLED_ATTRIBUTE, "disabled");
178         }
179     }
180
181     /**
182      * Is the current HTML tag disabled?
183      */

184     protected boolean isDisabled() {
185         return "true".equals(getDisabled());
186     }
187
188 }
189
Popular Tags