View Javadoc

1   /*
2    * $Id: TextArea.java 497654 2007-01-19 00:21:57Z rgielen $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.struts2.components;
22  
23  import javax.servlet.http.HttpServletRequest;
24  import javax.servlet.http.HttpServletResponse;
25  
26  import org.apache.struts2.views.annotations.StrutsTag;
27  import org.apache.struts2.views.annotations.StrutsTagAttribute;
28  
29  import com.opensymphony.xwork2.util.ValueStack;
30  
31  /***
32   * <!-- START SNIPPET: javadoc -->
33   * Render HTML textarea tag.</p>
34   * <!-- END SNIPPET: javadoc -->
35   *
36   * <p/> <b>Examples</b>
37   *
38   * <pre>
39   * <!-- START SNIPPET: example -->
40   * &lt;s:textarea label="Comments" name="comments" cols="30" rows="8"/&gt;
41   * <!-- END SNIPPET: example -->
42   * </pre>
43   *
44   * @see TabbedPanel
45   *
46   */
47  @StrutsTag(name="textarea", tldTagClass="org.apache.struts2.views.jsp.ui.TextareaTag", description="Render HTML textarea tag.")
48  public class TextArea extends UIBean {
49      final public static String TEMPLATE = "textarea";
50  
51      protected String cols;
52      protected String readonly;
53      protected String rows;
54      protected String wrap;
55  
56      public TextArea(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
57          super(stack, request, response);
58      }
59  
60      protected String getDefaultTemplate() {
61          return TEMPLATE;
62      }
63  
64      public void evaluateExtraParams() {
65          super.evaluateExtraParams();
66  
67          if (readonly != null) {
68              addParameter("readonly", findValue(readonly, Boolean.class));
69          }
70  
71          if (cols != null) {
72              addParameter("cols", findString(cols));
73          }
74  
75          if (rows != null) {
76              addParameter("rows", findString(rows));
77          }
78  
79          if (wrap != null) {
80              addParameter("wrap", findString(wrap));
81          }
82      }
83  
84      @StrutsTagAttribute(description="HTML cols attribute", type="Integer")
85      public void setCols(String cols) {
86          this.cols = cols;
87      }
88  
89      @StrutsTagAttribute(description="Whether the textarea is readonly", type="Boolean", defaultValue="false")
90      public void setReadonly(String readonly) {
91          this.readonly = readonly;
92      }
93  
94      @StrutsTagAttribute(description="HTML rows attribute", type="Integer")
95      public void setRows(String rows) {
96          this.rows = rows;
97      }
98  
99      @StrutsTagAttribute(description="HTML wrap attribute")
100     public void setWrap(String wrap) {
101         this.wrap = wrap;
102     }
103 }