1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.components;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.apache.struts2.views.annotations.StrutsTag;
28 import org.apache.struts2.views.annotations.StrutsTagAttribute;
29
30 import com.opensymphony.xwork2.util.ValueStack;
31
32 /***
33 * <!-- START SNIPPET: javadoc -->
34 * Render HTML textarea tag.</p>
35 * <!-- END SNIPPET: javadoc -->
36 *
37 * <p/> <b>Examples</b>
38 *
39 * <pre>
40 * <!-- START SNIPPET: example -->
41 * <s:textarea label="Comments" name="comments" cols="30" rows="8"/>
42 * <!-- END SNIPPET: example -->
43 * </pre>
44 *
45 * @see TabbedPanel
46 *
47 */
48 @StrutsTag(
49 name="textarea",
50 tldTagClass="org.apache.struts2.views.jsp.ui.TextareaTag",
51 description="Render HTML textarea tag.",
52 allowDynamicAttributes=true)
53 public class TextArea extends UIBean {
54 final public static String TEMPLATE = "textarea";
55
56 protected String cols;
57 protected String readonly;
58 protected String rows;
59 protected String wrap;
60
61 public TextArea(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
62 super(stack, request, response);
63 }
64
65 protected String getDefaultTemplate() {
66 return TEMPLATE;
67 }
68
69 public void evaluateExtraParams() {
70 super.evaluateExtraParams();
71
72 if (readonly != null) {
73 addParameter("readonly", findValue(readonly, Boolean.class));
74 }
75
76 if (cols != null) {
77 addParameter("cols", findString(cols));
78 }
79
80 if (rows != null) {
81 addParameter("rows", findString(rows));
82 }
83
84 if (wrap != null) {
85 addParameter("wrap", findString(wrap));
86 }
87 }
88
89 @StrutsTagAttribute(description="HTML cols attribute", type="Integer")
90 public void setCols(String cols) {
91 this.cols = cols;
92 }
93
94 @StrutsTagAttribute(description="Whether the textarea is readonly", type="Boolean", defaultValue="false")
95 public void setReadonly(String readonly) {
96 this.readonly = readonly;
97 }
98
99 @StrutsTagAttribute(description="HTML rows attribute", type="Integer")
100 public void setRows(String rows) {
101 this.rows = rows;
102 }
103
104 @StrutsTagAttribute(description="HTML wrap attribute")
105 public void setWrap(String wrap) {
106 this.wrap = wrap;
107 }
108 }