001: /*
002: * $Id: TextareaTag.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.taglib.TagUtils;
024:
025: import javax.servlet.jsp.JspException;
026:
027: /**
028: * Custom tag for input fields of type "textarea".
029: *
030: * @version $Rev: 471754 $ $Date: 2005-04-06 02:37:00 -0400 (Wed, 06 Apr 2005)
031: * $
032: */
033: public class TextareaTag extends BaseInputTag {
034: // ----------------------------------------------------- Constructor
035: public TextareaTag() {
036: super ();
037: doReadonly = true;
038: }
039:
040: // --------------------------------------------------------- Public Methods
041:
042: /**
043: * Generate the required input tag. Support for indexed since Struts 1.1
044: *
045: * @throws JspException if a JSP exception has occurred
046: */
047: public int doStartTag() throws JspException {
048: TagUtils.getInstance().write(pageContext,
049: this .renderTextareaElement());
050:
051: return (EVAL_BODY_TAG);
052: }
053:
054: /**
055: * Generate an HTML <textarea> tag.
056: *
057: * @throws JspException
058: * @since Struts 1.1
059: */
060: protected String renderTextareaElement() throws JspException {
061: StringBuffer results = new StringBuffer("<textarea");
062:
063: prepareAttribute(results, "name", prepareName());
064: prepareAttribute(results, "accesskey", getAccesskey());
065: prepareAttribute(results, "tabindex", getTabindex());
066: prepareAttribute(results, "cols", getCols());
067: prepareAttribute(results, "rows", getRows());
068: results.append(prepareEventHandlers());
069: results.append(prepareStyles());
070: prepareOtherAttributes(results);
071: results.append(">");
072:
073: results.append(this .renderData());
074:
075: results.append("</textarea>");
076:
077: return results.toString();
078: }
079:
080: /**
081: * Renders the value displayed in the <textarea> tag.
082: *
083: * @throws JspException
084: * @since Struts 1.1
085: */
086: protected String renderData() throws JspException {
087: String data = this .value;
088:
089: if (data == null) {
090: data = this .lookupProperty(this .name, this .property);
091: }
092:
093: return (data == null) ? "" : TagUtils.getInstance()
094: .filter(data);
095: }
096:
097: /**
098: * Release any acquired resources.
099: */
100: public void release() {
101: super.release();
102: name = Constants.BEAN_KEY;
103: }
104: }
|