001: /*
002: * $Id: BaseInputTag.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.taglib.html;
022:
023: import org.apache.struts.util.MessageResources;
024:
025: import javax.servlet.jsp.JspException;
026:
027: /**
028: * Abstract base class for the various input tags.
029: *
030: * @version $Rev: 471754 $ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
031: * $
032: */
033: public abstract class BaseInputTag extends BaseHandlerTag {
034: /**
035: * The message resources for this package.
036: */
037: protected static MessageResources messages = MessageResources
038: .getMessageResources(Constants.Package + ".LocalStrings");
039:
040: // ----------------------------------------------------- Instance Variables
041:
042: /**
043: * The number of character columns for this field, or negative for no
044: * limit.
045: */
046: protected String cols = null;
047:
048: /**
049: * The maximum number of characters allowed, or negative for no limit.
050: */
051: protected String maxlength = null;
052:
053: /**
054: * The name of the field (and associated property) being processed.
055: */
056: protected String property = null;
057:
058: /**
059: * The number of rows for this field, or negative for no limit.
060: */
061: protected String rows = null;
062:
063: /**
064: * The value for this field, or <code>null</code> to retrieve the
065: * corresponding property from our associated bean.
066: */
067: protected String value = null;
068:
069: /**
070: * The name of the bean containing our underlying property.
071: */
072: protected String name = Constants.BEAN_KEY;
073:
074: // ------------------------------------------------------------- Properties
075: public String getName() {
076: return (this .name);
077: }
078:
079: public void setName(String name) {
080: this .name = name;
081: }
082:
083: /**
084: * Return the number of columns for this field.
085: */
086: public String getCols() {
087: return (this .cols);
088: }
089:
090: /**
091: * Set the number of columns for this field.
092: *
093: * @param cols The new number of columns
094: */
095: public void setCols(String cols) {
096: this .cols = cols;
097: }
098:
099: /**
100: * Return the maximum length allowed.
101: */
102: public String getMaxlength() {
103: return (this .maxlength);
104: }
105:
106: /**
107: * Set the maximum length allowed.
108: *
109: * @param maxlength The new maximum length
110: */
111: public void setMaxlength(String maxlength) {
112: this .maxlength = maxlength;
113: }
114:
115: /**
116: * Return the property name.
117: */
118: public String getProperty() {
119: return (this .property);
120: }
121:
122: /**
123: * Set the property name.
124: *
125: * @param property The new property name
126: */
127: public void setProperty(String property) {
128: this .property = property;
129: }
130:
131: /**
132: * Return the number of rows for this field.
133: */
134: public String getRows() {
135: return (this .rows);
136: }
137:
138: /**
139: * Set the number of rows for this field.
140: *
141: * @param rows The new number of rows
142: */
143: public void setRows(String rows) {
144: this .rows = rows;
145: }
146:
147: /**
148: * Return the size of this field (synonym for <code>getCols()</code>).
149: */
150: public String getSize() {
151: return (getCols());
152: }
153:
154: /**
155: * Set the size of this field (synonym for <code>setCols()</code>).
156: *
157: * @param size The new size
158: */
159: public void setSize(String size) {
160: setCols(size);
161: }
162:
163: /**
164: * Return the field value (if any).
165: */
166: public String getValue() {
167: return (this .value);
168: }
169:
170: /**
171: * Set the field value (if any).
172: *
173: * @param value The new field value, or <code>null</code> to retrieve the
174: * corresponding property from the bean
175: */
176: public void setValue(String value) {
177: this .value = value;
178: }
179:
180: // --------------------------------------------------------- Public Methods
181:
182: /**
183: * Process the start of this tag. The default implementation does
184: * nothing.
185: *
186: * @throws JspException if a JSP exception has occurred
187: */
188: public int doStartTag() throws JspException {
189: return (EVAL_BODY_TAG);
190: }
191:
192: /**
193: * Process the end of this tag. The default implementation does nothing.
194: *
195: * @throws JspException if a JSP exception has occurred
196: */
197: public int doEndTag() throws JspException {
198: return (EVAL_PAGE);
199: }
200:
201: /**
202: * Prepare the name element
203: *
204: * @return The element name.
205: */
206: protected String prepareName() throws JspException {
207: if (property == null) {
208: return null;
209: }
210:
211: // * @since Struts 1.1
212: if (indexed) {
213: StringBuffer results = new StringBuffer();
214:
215: prepareIndex(results, name);
216: results.append(property);
217:
218: return results.toString();
219: }
220:
221: return property;
222: }
223:
224: /**
225: * Release any acquired resources.
226: */
227: public void release() {
228: super.release();
229: name = Constants.BEAN_KEY;
230: cols = null;
231: maxlength = null;
232: property = null;
233: rows = null;
234: value = null;
235: }
236: }
|