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