KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > html > BaseInputTag


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

18
19 package org.apache.struts.taglib.html;
20
21 import javax.servlet.jsp.JspException JavaDoc;
22 import org.apache.struts.util.MessageResources;
23
24 /**
25  * Abstract base class for the various input tags.
26  *
27  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
28  */

29 public abstract class BaseInputTag extends BaseHandlerTag {
30
31     // ----------------------------------------------------- Instance Variables
32

33     /**
34      * The number of character columns for this field, or negative
35      * for no limit.
36      */

37     protected String JavaDoc cols = null;
38
39     /**
40      * The maximum number of characters allowed, or negative for no limit.
41      */

42     protected String JavaDoc maxlength = null;
43
44     /**
45      * The message resources for this package.
46      */

47     protected static MessageResources messages =
48         MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
49
50     /**
51      * The name of the field (and associated property) being processed.
52      */

53     protected String JavaDoc property = null;
54
55     /**
56      * The number of rows for this field, or negative for no limit.
57      */

58     protected String JavaDoc rows = null;
59
60     /**
61      * The value for this field, or <code>null</code> to retrieve the
62      * corresponding property from our associated bean.
63      */

64     protected String JavaDoc value = null;
65
66     /**
67      * The name of the bean containing our underlying property.
68      */

69     protected String JavaDoc name = Constants.BEAN_KEY;
70
71     // ------------------------------------------------------------- Properties
72

73     public String JavaDoc getName() {
74         return (this.name);
75     }
76
77     public void setName(String JavaDoc name) {
78         this.name = name;
79     }
80
81     /**
82      * Return the number of columns for this field.
83      */

84     public String JavaDoc getCols() {
85
86         return (this.cols);
87
88     }
89
90     /**
91      * Set the number of columns for this field.
92      *
93      * @param cols The new number of columns
94      */

95     public void setCols(String JavaDoc cols) {
96
97         this.cols = cols;
98
99     }
100
101     /**
102      * Return the maximum length allowed.
103      */

104     public String JavaDoc getMaxlength() {
105
106         return (this.maxlength);
107
108     }
109
110     /**
111      * Set the maximum length allowed.
112      *
113      * @param maxlength The new maximum length
114      */

115     public void setMaxlength(String JavaDoc maxlength) {
116
117         this.maxlength = maxlength;
118
119     }
120
121     /**
122      * Return the property name.
123      */

124     public String JavaDoc getProperty() {
125
126         return (this.property);
127
128     }
129
130     /**
131      * Set the property name.
132      *
133      * @param property The new property name
134      */

135     public void setProperty(String JavaDoc property) {
136
137         this.property = property;
138
139     }
140
141     /**
142      * Return the number of rows for this field.
143      */

144     public String JavaDoc getRows() {
145
146         return (this.rows);
147
148     }
149
150     /**
151      * Set the number of rows for this field.
152      *
153      * @param rows The new number of rows
154      */

155     public void setRows(String JavaDoc rows) {
156
157         this.rows = rows;
158
159     }
160
161     /**
162      * Return the size of this field (synonym for <code>getCols()</code>).
163      */

164     public String JavaDoc getSize() {
165
166         return (getCols());
167
168     }
169
170     /**
171      * Set the size of this field (synonym for <code>setCols()</code>).
172      *
173      * @param size The new size
174      */

175     public void setSize(String JavaDoc size) {
176
177         setCols(size);
178
179     }
180
181     /**
182      * Return the field value (if any).
183      */

184     public String JavaDoc getValue() {
185
186         return (this.value);
187
188     }
189
190     /**
191      * Set the field value (if any).
192      *
193      * @param value The new field value, or <code>null</code> to retrieve the
194      * corresponding property from the bean
195      */

196     public void setValue(String JavaDoc value) {
197
198         this.value = value;
199
200     }
201
202     // --------------------------------------------------------- Public Methods
203

204     /**
205      * Process the start of this tag. The default implementation does nothing.
206      *
207      * @exception JspException if a JSP exception has occurred
208      */

209     public int doStartTag() throws JspException JavaDoc {
210
211         return (EVAL_BODY_TAG);
212
213     }
214
215     /**
216      * Process the end of this tag. The default implementation does nothing.
217      *
218      * @exception JspException if a JSP exception has occurred
219      */

220     public int doEndTag() throws JspException JavaDoc {
221
222         return (EVAL_PAGE);
223
224     }
225
226     /**
227      * Prepare the name element
228      * @return The element name.
229      */

230     protected String JavaDoc prepareName() throws JspException JavaDoc {
231
232         if (property == null) {
233             return null;
234         }
235
236         // * @since Struts 1.1
237
if(indexed) {
238             StringBuffer JavaDoc results = new StringBuffer JavaDoc();
239             prepareIndex(results, name);
240             results.append(property);
241             return results.toString();
242         }
243
244         return property;
245
246     }
247
248     /**
249      * Release any acquired resources.
250      */

251     public void release() {
252
253         super.release();
254         name = Constants.BEAN_KEY;
255         cols = null;
256         maxlength = null;
257         property = null;
258         rows = null;
259         value = null;
260
261     }
262
263 }
264
Popular Tags