KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TextareaTag.java 164530 2005-04-25 03:11:07Z niallp $
3  *
4  * Copyright 1999-2005 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
23 import org.apache.struts.taglib.TagUtils;
24
25 /**
26  * Custom tag for input fields of type "textarea".
27  *
28  * @version $Rev: 164530 $ $Date: 2005-04-25 04:11:07 +0100 (Mon, 25 Apr 2005) $
29  */

30 public class TextareaTag extends BaseInputTag {
31
32
33     // ----------------------------------------------------- Constructor
34

35     public TextareaTag () {
36         super();
37         doReadonly = true;
38     }
39
40     // --------------------------------------------------------- Public Methods
41

42
43     /**
44      * Generate the required input tag.
45      * Support for indexed since Struts 1.1
46      *
47      * @exception JspException if a JSP exception has occurred
48      */

49     public int doStartTag() throws JspException JavaDoc {
50         
51         TagUtils.getInstance().write(pageContext, this.renderTextareaElement());
52
53         return (EVAL_BODY_TAG);
54     }
55
56     /**
57      * Generate an HTML <textarea> tag.
58      * @throws JspException
59      * @since Struts 1.1
60      */

61     protected String JavaDoc renderTextareaElement() throws JspException JavaDoc {
62         StringBuffer JavaDoc results = new StringBuffer JavaDoc("<textarea");
63         
64         prepareAttribute(results, "name", prepareName());
65         prepareAttribute(results, "accesskey", getAccesskey());
66         prepareAttribute(results, "tabindex", getTabindex());
67         prepareAttribute(results, "cols", getCols());
68         prepareAttribute(results, "rows", getRows());
69         results.append(prepareEventHandlers());
70         results.append(prepareStyles());
71         prepareOtherAttributes(results);
72         results.append(">");
73         
74         results.append(this.renderData());
75         
76         results.append("</textarea>");
77         return results.toString();
78     }
79
80     /**
81      * Renders the value displayed in the &lt;textarea&gt; tag.
82      * @throws JspException
83      * @since Struts 1.1
84      */

85     protected String JavaDoc renderData() throws JspException JavaDoc {
86         String JavaDoc data = this.value;
87
88         if (data == null) {
89             data = this.lookupProperty(this.name, this.property);
90         }
91         
92         return (data == null) ? "" : TagUtils.getInstance().filter(data);
93     }
94
95     /**
96      * Release any acquired resources.
97      */

98     public void release() {
99
100         super.release();
101         name = Constants.BEAN_KEY;
102
103     }
104
105 }
106
Popular Tags