1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts.taglib.html;
22
23 import org.apache.struts.taglib.TagUtils;
24
25 import javax.servlet.jsp.JspException;
26
27 /**
28 * Custom tag for input fields of type "textarea".
29 *
30 * @version $Rev: 471754 $ $Date: 2005-04-06 02:37:00 -0400 (Wed, 06 Apr 2005)
31 * $
32 */
33 public class TextareaTag extends BaseInputTag {
34
35 public TextareaTag() {
36 super();
37 doReadonly = true;
38 }
39
40
41
42 /**
43 * Generate the required input tag. Support for indexed since Struts 1.1
44 *
45 * @throws JspException if a JSP exception has occurred
46 */
47 public int doStartTag() throws JspException {
48 TagUtils.getInstance().write(pageContext, this.renderTextareaElement());
49
50 return (EVAL_BODY_TAG);
51 }
52
53 /**
54 * Generate an HTML <textarea> tag.
55 *
56 * @throws JspException
57 * @since Struts 1.1
58 */
59 protected String renderTextareaElement()
60 throws JspException {
61 StringBuffer results = new StringBuffer("<textarea");
62
63 prepareAttribute(results, "name", prepareName());
64 prepareAttribute(results, "accesskey", getAccesskey());
65 prepareAttribute(results, "tabindex", getTabindex());
66 prepareAttribute(results, "cols", getCols());
67 prepareAttribute(results, "rows", getRows());
68 results.append(prepareEventHandlers());
69 results.append(prepareStyles());
70 prepareOtherAttributes(results);
71 results.append(">");
72
73 results.append(this.renderData());
74
75 results.append("</textarea>");
76
77 return results.toString();
78 }
79
80 /**
81 * Renders the value displayed in the <textarea> tag.
82 *
83 * @throws JspException
84 * @since Struts 1.1
85 */
86 protected String renderData()
87 throws JspException {
88 String data = this.value;
89
90 if (data == null) {
91 data = this.lookupProperty(this.name, this.property);
92 }
93
94 return (data == null) ? "" : TagUtils.getInstance().filter(data);
95 }
96
97 /**
98 * Release any acquired resources.
99 */
100 public void release() {
101 super.release();
102 name = Constants.BEAN_KEY;
103 }
104 }