View Javadoc

1   /*
2    Wotonomy: OpenStep design patterns for pure Java applications.
3    Copyright (C) 2000 Blacksmith, Inc.
4   
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9   
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14  
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, see http://www.gnu.org
17   */
18  
19  package net.wotonomy.web;
20  
21  import net.wotonomy.foundation.NSArray;
22  import net.wotonomy.foundation.NSDictionary;
23  
24  /***
25  * Implements a TEXTAREA element, with dynamic bindings.
26   * @author michael@mpowers.net
27   * @author $Author: cgruber $
28   * @version $Revision: 905 $
29   */
30  public class WOText extends WOInput {
31  
32      public WOText() {
33          super();
34      }
35  
36      public WOText(String n, NSDictionary m, WOElement t) {
37          super(n, m, t);
38      }
39  
40  	protected String inputType() {
41  		return "TEXTAREA";
42  	}
43  
44  	protected Object value(WOContext c) {
45  		Object fieldValue = valueForProperty("value", c.component());
46  		if (fieldValue == null) {
47  			fieldValue = "";
48  		}
49  		return formattedValue(fieldValue, c.component());
50  	}
51  
52      public void takeValuesFromRequest(WORequest r, WOContext c) {
53          Object val = r.formValueForKey(inputName(c));
54          if ( val != null )
55              setValueForProperty("value", formattedValue(val, c.component()), c.component());
56      }
57  
58      public void appendToResponse(WOResponse r, WOContext c) {
59          r.appendContentString("<TEXTAREA NAME=\"");
60          r.appendContentString(inputName(c));
61          r.appendContentString("\"");
62          String moreFields = additionalHTMLProperties(c.component(), new NSArray(new Object[]{
63              "name", "value" }));
64          if (moreFields != null && moreFields.length() > 0)
65              r.appendContentString(moreFields);
66          r.appendContentString(">");
67          moreFields = value(c).toString();
68          if (moreFields != null && moreFields.length() > 0)
69              r.appendContentString(moreFields);
70          r.appendContentString("</TEXTAREA>");
71      }
72  }