View Javadoc

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