KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > xhtml > 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.xhtml;
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.2 2003/04/27 09:36:17 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     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
69 */

70 public class textarea extends MultiPartElement implements PageEvents, FormEvents, MouseEvents, KeyEvents
71 {
72     public final static String JavaDoc off = "off";
73     public final static String JavaDoc physical = "physical";
74     public final static String JavaDoc virtual = "virtual";
75     
76     /**
77         Private initializer.
78     */

79     {
80         setElementType("textarea");
81         setCase(LOWERCASE);
82         setAttributeQuote(true);
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", "readonly");
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", "disabled");
241         else
242             removeAttribute("disabled");
243             
244         return(this);
245     }
246     
247     /**
248         Sets the lang="" and xml:lang="" attributes
249         @param lang the lang="" and xml:lang="" attributes
250     */

251     public Element setLang(String JavaDoc lang)
252     {
253         addAttribute("lang",lang);
254         addAttribute("xml:lang",lang);
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,Element element)
264     {
265         addElementToRegistry(hashcode,element);
266         return(this);
267     }
268
269     /**
270         Adds an Element to the element.
271         @param hashcode name of element for hash table
272         @param element Adds an Element to the element.
273      */

274     public textarea addElement(String JavaDoc hashcode,String JavaDoc element)
275     {
276         addElementToRegistry(hashcode,element);
277         return(this);
278     }
279
280     /**
281         Adds an Element to the element.
282         @param element Adds an Element to the element.
283      */

284     public textarea addElement(Element element)
285     {
286         addElementToRegistry(element);
287         return(this);
288     }
289
290     /**
291         Adds an Element to the element.
292         @param element Adds an Element to the element.
293      */

294     public textarea addElement(String JavaDoc element)
295     {
296         addElementToRegistry(element);
297         return(this);
298     }
299     /**
300         Removes an Element from the element.
301         @param hashcode the name of the element to be removed.
302     */

303     public textarea removeElement(String JavaDoc hashcode)
304     {
305         removeElementFromRegistry(hashcode);
306         return(this);
307     }
308
309     /**
310         The onload event occurs when the user agent finishes loading a window
311         or all frames within a frameset. This attribute may be used with body
312         and frameset elements.
313         
314         @param The script
315     */

316     public void setOnLoad(String JavaDoc script)
317     {
318         addAttribute ( "onload", script );
319     }
320
321     /**
322         The onunload event occurs when the user agent removes a document from a
323         window or frame. This attribute may be used with body and frameset
324         elements.
325         
326         @param The script
327     */

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

339     public void setOnSubmit(String JavaDoc script)
340     {
341         addAttribute ( "onsubmit", script );
342     }
343
344     /**
345         The onreset event occurs when a form is reset. It only applies to the
346         FORM element.
347         
348         @param The script
349     */

350     public void setOnReset(String JavaDoc script)
351     {
352         addAttribute ( "onreset", script );
353     }
354
355     /**
356         The onselect event occurs when a user selects some text in a text
357         field. This attribute may be used with the input and textarea elements.
358         
359         @param The script
360     */

361     public void setOnSelect(String JavaDoc script)
362     {
363         addAttribute ( "onselect", script );
364     }
365
366     /**
367         The onchange event occurs when a control loses the input focus and its
368         value has been modified since gaining focus. This attribute applies to
369         the following elements: input, select, and textarea.
370         
371         @param The script
372     */

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

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

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

404     public void setOnMouseDown(String JavaDoc script)
405     {
406         addAttribute ( "onmousedown", script );
407     }
408     /**
409         The onmouseup event occurs when the pointing device button is released
410         over an element. This attribute may be used with most elements.
411
412         @param The script
413     */

414     public void setOnMouseUp(String JavaDoc script)
415     {
416         addAttribute ( "onmouseup", script );
417     }
418     /**
419         The onmouseover event occurs when the pointing device is moved onto an
420         element. This attribute may be used with most elements.
421
422         @param The script
423     */

424     public void setOnMouseOver(String JavaDoc script)
425     {
426         addAttribute ( "onmouseover", script );
427     }
428     /**
429         The onmousemove event occurs when the pointing device is moved while it
430         is over an element. This attribute may be used with most elements.
431
432         @param The script
433     */

434     public void setOnMouseMove(String JavaDoc script)
435     {
436         addAttribute ( "onmousemove", script );
437     }
438     /**
439         The onmouseout event occurs when the pointing device is moved away from
440         an element. This attribute may be used with most elements.
441
442         @param The script
443     */

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

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

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

477     public void setOnKeyUp(String JavaDoc script)
478     {
479         addAttribute ( "onkeyup", script );
480     }
481 }
482
Popular Tags