KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > TextArea


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.html;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;TEXTAREA&gt;&lt;/TEXTAREA&gt; tag.
64
65     @version $Id: TextArea.java,v 1.7 2003/04/27 09:03:39 rdonkin Exp $
66     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
67     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
68 */

69 public class TextArea extends MultiPartElement implements PageEvents, FormEvents, MouseEvents, KeyEvents, FocusEvents
70 {
71     public final static String JavaDoc off = "off";
72     public final static String JavaDoc physical = "physical";
73     public final static String JavaDoc virtual = "virtual";
74     public final static String JavaDoc OFF = "OFF";
75     public final static String JavaDoc PHYSICAL = "PHYSICAL";
76     public final static String JavaDoc VIRTUAL = "VIRTUAL";
77     
78     /**
79         Private initializer.
80     */

81     {
82         setElementType("textarea");
83     }
84     /**
85         Basic Constructor use set* methods.
86     */

87     public TextArea()
88     {
89     }
90
91     /**
92         Basic Constructor use set* methods.
93         @param rows the ROWS="" attribute
94         @param cols the COLS="" attribute
95     */

96     public TextArea(int rows, int cols)
97     {
98         setRows(rows);
99         setCols(cols);
100     }
101     
102     /**
103         Basic Constructor use set* methods.
104         @param rows the ROWS="" attribute
105         @param cols the COLS="" attribute
106     */

107     public TextArea(String JavaDoc rows, String JavaDoc cols)
108     {
109         setRows(rows);
110         setCols(cols);
111     }
112     
113     /**
114         Basic Constructor use set* methods.
115         @param name the NAME="" attribute
116         @param rows the ROWS="" attribute
117         @param cols the COLS="" attribute
118     */

119     public TextArea(String JavaDoc name, int rows, int cols)
120     {
121         setName(name);
122         setRows(rows);
123         setCols(cols);
124     }
125     
126     /**
127         Basic Constructor use set* methods.
128         @param name the NAME="" attribute
129         @param rows the ROWS="" attribute
130         @param cols the COLS="" attribute
131     */

132     public TextArea(String JavaDoc name, String JavaDoc rows, String JavaDoc cols)
133     {
134         setName(name);
135         setRows(rows);
136         setCols(cols);
137     }
138     
139     /**
140         Sets the ROWS="" attribute
141         @param rows Sets the ROWS="" attribute
142     */

143     public TextArea setRows(int rows)
144     {
145         setRows(Integer.toString(rows));
146         return(this);
147     }
148
149     /**
150         Sets the ROWS="" attribute
151         @param rows Sets the ROWS="" attribute
152     */

153     public TextArea setRows(String JavaDoc rows)
154     {
155         addAttribute("rows",rows);
156         return(this);
157     }
158
159     /**
160         Sets the WRAP="" attribute
161         @param wrap Sets the WRAP="" attribute
162     */

163     public TextArea setWrap(String JavaDoc wrap)
164     {
165         addAttribute("wrap",wrap);
166         return(this);
167     }
168
169     /**
170         Sets the COLS="" attribute
171         @param cols Sets the COLS="" attribute
172     */

173     public TextArea setCols(int cols)
174     {
175         setCols(Integer.toString(cols));
176         return(this);
177     }
178
179     /**
180         Sets the COLS="" attribute
181         @param cols Sets the COLS="" attribute
182     */

183     public TextArea setCols(String JavaDoc cols)
184     {
185         addAttribute("cols",cols);
186         return(this);
187     }
188
189     /**
190         Sets the NAME="" attribute
191         @param name Sets the NAME="" attribute
192     */

193     public TextArea setName(String JavaDoc name)
194     {
195         addAttribute("name",name);
196         return(this);
197     }
198
199     /**
200         Sets the TABINDEX="" attribute
201         @param alt the TABINDEX="" attribute
202     */

203     public TextArea setTabindex(String JavaDoc index)
204     {
205         addAttribute("tabindex",index);
206         return this;
207     }
208     
209     /**
210         Sets the TABINDEX="" attribute
211         @param alt the TABINDEX="" attribute
212     */

213     public TextArea setTabindex(int index)
214     {
215         setTabindex(Integer.toString(index));
216         return this;
217     }
218     
219     /**
220         Sets the readonly value
221         @param readonly true or false
222     */

223     public TextArea setReadOnly(boolean readonly)
224     {
225         if ( readonly == true )
226             addAttribute("readonly", NO_ATTRIBUTE_VALUE);
227         else
228             removeAttribute("readonly");
229             
230         return(this);
231     }
232
233     /**
234         Sets the disabled value
235         @param disabled true or false
236     */

237     public TextArea setDisabled(boolean disabled)
238     {
239         if ( disabled == true )
240             addAttribute("disabled", NO_ATTRIBUTE_VALUE);
241         else
242             removeAttribute("disabled");
243             
244         return(this);
245     }
246     
247     /**
248         Adds an Element to the element.
249         @param hashcode name of element for hash table
250         @param element Adds an Element to the element.
251      */

252     public TextArea addElement(String JavaDoc hashcode,Element element)
253     {
254         addElementToRegistry(hashcode,element);
255         return(this);
256     }
257
258     /**
259         Adds an Element to the element.
260         @param hashcode name of element for hash table
261         @param element Adds an Element to the element.
262      */

263     public TextArea addElement(String JavaDoc hashcode,String JavaDoc element)
264     {
265         addElementToRegistry(hashcode,element);
266         return(this);
267     }
268
269     /**
270         Adds an Element to the element.
271         @param element Adds an Element to the element.
272      */

273     public TextArea addElement(Element element)
274     {
275         addElementToRegistry(element);
276         return(this);
277     }
278
279     /**
280         Adds an Element to the element.
281         @param element Adds an Element to the element.
282      */

283     public TextArea addElement(String JavaDoc element)
284     {
285         addElementToRegistry(element);
286         return(this);
287     }
288     /**
289         Removes an Element from the element.
290         @param hashcode the name of the element to be removed.
291     */

292     public TextArea removeElement(String JavaDoc hashcode)
293     {
294         removeElementFromRegistry(hashcode);
295         return(this);
296     }
297
298     /**
299         The onload event occurs when the user agent finishes loading a window
300         or all frames within a FRAMESET. This attribute may be used with BODY
301         and FRAMESET elements.
302         
303         @param The script
304     */

305     public void setOnLoad(String JavaDoc script)
306     {
307         addAttribute ( "onLoad", script );
308     }
309
310     /**
311         The onunload event occurs when the user agent removes a document from a
312         window or frame. This attribute may be used with BODY and FRAMESET
313         elements.
314         
315         @param The script
316     */

317     public void setOnUnload(String JavaDoc script)
318     {
319         addAttribute ( "onUnload", script );
320     }
321
322     /**
323         The onsubmit event occurs when a form is submitted. It only applies to
324         the FORM element.
325         
326         @param The script
327     */

328     public void setOnSubmit(String JavaDoc script)
329     {
330         addAttribute ( "onSubmit", script );
331     }
332
333     /**
334         The onreset event occurs when a form is reset. It only applies to the
335         FORM element.
336         
337         @param The script
338     */

339     public void setOnReset(String JavaDoc script)
340     {
341         addAttribute ( "onReset", script );
342     }
343
344     /**
345         The onselect event occurs when a user selects some text in a text
346         field. This attribute may be used with the INPUT and TEXTAREA elements.
347         
348         @param The script
349     */

350     public void setOnSelect(String JavaDoc script)
351     {
352         addAttribute ( "onSelect", script );
353     }
354
355     /**
356         The onchange event occurs when a control loses the input focus and its
357         value has been modified since gaining focus. This attribute applies to
358         the following elements: INPUT, SELECT, and TEXTAREA.
359         
360         @param The script
361     */

362     public void setOnChange(String JavaDoc script)
363     {
364         addAttribute ( "onChange", script );
365     }
366
367     /**
368         The onclick event occurs when the pointing device button is clicked
369         over an element. This attribute may be used with most elements.
370         
371         @param The script
372     */

373     public void setOnClick(String JavaDoc script)
374     {
375         addAttribute ( "onClick", script );
376     }
377     /**
378         The ondblclick event occurs when the pointing device button is double
379         clicked over an element. This attribute may be used with most elements.
380
381         @param The script
382     */

383     public void setOnDblClick(String JavaDoc script)
384     {
385         addAttribute ( "onDblClick", script );
386     }
387     /**
388         The onmousedown event occurs when the pointing device button is pressed
389         over an element. This attribute may be used with most elements.
390
391         @param The script
392     */

393     public void setOnMouseDown(String JavaDoc script)
394     {
395         addAttribute ( "onMouseDown", script );
396     }
397     /**
398         The onmouseup event occurs when the pointing device button is released
399         over an element. This attribute may be used with most elements.
400
401         @param The script
402     */

403     public void setOnMouseUp(String JavaDoc script)
404     {
405         addAttribute ( "onMouseUp", script );
406     }
407     /**
408         The onmouseover event occurs when the pointing device is moved onto an
409         element. This attribute may be used with most elements.
410
411         @param The script
412     */

413     public void setOnMouseOver(String JavaDoc script)
414     {
415         addAttribute ( "onMouseOver", script );
416     }
417     /**
418         The onmousemove event occurs when the pointing device is moved while it
419         is over an element. This attribute may be used with most elements.
420
421         @param The script
422     */

423     public void setOnMouseMove(String JavaDoc script)
424     {
425         addAttribute ( "onMouseMove", script );
426     }
427     /**
428         The onmouseout event occurs when the pointing device is moved away from
429         an element. This attribute may be used with most elements.
430
431         @param The script
432     */

433     public void setOnMouseOut(String JavaDoc script)
434     {
435         addAttribute ( "onMouseOut", script );
436     }
437
438     /**
439         The onkeypress event occurs when a key is pressed and released over an
440         element. This attribute may be used with most elements.
441         
442         @param The script
443     */

444     public void setOnKeyPress(String JavaDoc script)
445     {
446         addAttribute ( "onKeyPress", script );
447     }
448
449     /**
450         The onkeydown event occurs when a key is pressed down over an element.
451         This attribute may be used with most elements.
452         
453         @param The script
454     */

455     public void setOnKeyDown(String JavaDoc script)
456     {
457         addAttribute ( "onKeyDown", script );
458     }
459
460     /**
461         The onkeyup event occurs when a key is released over an element. This
462         attribute may be used with most elements.
463         
464         @param The script
465     */

466     public void setOnKeyUp(String JavaDoc script)
467     {
468         addAttribute ( "onKeyUp", script );
469     }
470
471     /**
472         The onFocus event occurs when a element is focussed. This
473         attribute may be used with most elements.
474
475         @param The script
476     */

477     public void setOnFocus(String JavaDoc script)
478     {
479         addAttribute ( "onFocus", script );
480     }
481
482     /**
483         The onBlur event occurs when a element is blurred. This
484         attribute may be used with most elements.
485
486         @param The script
487     */

488     public void setOnBlur(String JavaDoc script)
489     {
490         addAttribute ( "onBlur", script );
491     }
492 }
493
Popular Tags