1 38 package com.gargoylesoftware.htmlunit.html; 39 40 import com.gargoylesoftware.htmlunit.KeyValuePair; 41 42 import java.util.Map ; 43 44 55 public class HtmlTextArea extends FocusableElement implements DisabledElement, SubmittableElement { 56 57 58 public static final String TAG_NAME = "textarea"; 59 60 private DomText oldText_; 61 62 68 public HtmlTextArea( final HtmlPage page, final Map attributes ) { 69 super( page, attributes ); 70 } 71 72 75 public String getTagName() { 76 return TAG_NAME; 77 } 78 79 85 public final String getValue() { 86 return getText(); 87 } 88 89 90 95 public final String getText() { 96 return getChildrenAsText(); 97 } 98 99 100 107 public final void setValue( final String newValue ) { 108 if( newValue == null ) { 109 reset(); 110 } 111 else { 112 setText(newValue); 113 } 114 } 115 116 117 122 public final void setText( final String newValue ) { 123 oldText_ = (DomText)getFirstChild(); 124 final DomText newText = new DomText(getPage(), newValue); 125 if (oldText_ == null) { 126 appendChild(newText); 127 } 128 else { 129 oldText_.replace(newText); 130 } 131 132 getPage().executeOnChangeHandlerIfAppropriate(this); 133 } 134 135 136 145 public KeyValuePair[] getSubmitKeyValuePairs() { 146 return new KeyValuePair[]{new KeyValuePair( getNameAttribute(), getText() )}; 147 } 148 149 150 153 public void reset() { 154 if(oldText_ != null) { 155 getFirstChild().replace(oldText_); 156 } 157 } 158 159 160 168 public final String getNameAttribute() { 169 return getAttributeValue("name"); 170 } 171 172 173 181 public final String getRowsAttribute() { 182 return getAttributeValue("rows"); 183 } 184 185 186 194 public final String getColumnsAttribute() { 195 return getAttributeValue("cols"); 196 } 197 198 199 204 public final boolean isDisabled() { 205 return isAttributeDefined("disabled"); 206 } 207 208 209 217 public final String getDisabledAttribute() { 218 return getAttributeValue("disabled"); 219 } 220 221 222 230 public final String getReadOnlyAttribute() { 231 return getAttributeValue("readonly"); 232 } 233 234 235 243 public final String getTabIndexAttribute() { 244 return getAttributeValue("tabindex"); 245 } 246 247 248 256 public final String getAccessKeyAttribute() { 257 return getAttributeValue("accesskey"); 258 } 259 260 261 269 public final String getOnFocusAttribute() { 270 return getAttributeValue("onfocus"); 271 } 272 273 274 282 public final String getOnBlurAttribute() { 283 return getAttributeValue("onblur"); 284 } 285 286 287 295 public final String getOnSelectAttribute() { 296 return getAttributeValue("onselect"); 297 } 298 299 300 308 public final String getOnChangeAttribute() { 309 return getAttributeValue("onchange"); 310 } 311 } 312 | Popular Tags |