KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > xhtml > optgroup


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;optgroup&gt; tag.
64
65     @version $Id: optgroup.java,v 1.2 2003/04/27 09:37:58 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 optgroup extends MultiPartElement implements Printable, FocusEvents, FormEvents, MouseEvents, KeyEvents
71 {
72
73     /**
74         Private initialization routine.
75     */

76     {
77         setElementType("optgroup");
78         setCase(LOWERCASE);
79         setAttributeQuote(true);
80     }
81     
82     /**
83         Basic constructor. Use the set* methods to set the values
84         of the attributes.
85     */

86     public optgroup()
87     {
88     }
89     
90     /**
91         Basic constructor. Use the set* methods to set the values
92         of the attributes.
93         
94         @param label sets the attribute label=""
95     */

96     public optgroup(String JavaDoc label)
97     {
98         setLabel(label);
99     }
100
101     /**
102         Basic constructor. Use the set* methods to set the values
103         of the attributes.
104         
105         @param label sets the attribute label=""
106         @param disabled sets the attribute disabled=
107     */

108     public optgroup(String JavaDoc label, boolean disabled)
109     {
110         setLabel(label);
111         setDisabled(disabled);
112     }
113
114     /**
115         sets the label="" attribute
116         @param label the label="" attribute
117     */

118     public optgroup setLabel(String JavaDoc label)
119     {
120         addAttribute("label",label);
121         return this;
122     }
123
124     /**
125         Sets the value="" attribute
126         @param value the value="" attribute
127     */

128     public optgroup setValue(String JavaDoc value)
129     {
130         addAttribute("value",value);
131         return this;
132     }
133
134     /**
135         Sets the disabled value
136         @param disabled true or false
137     */

138     public optgroup setDisabled(boolean disabled)
139     {
140         if ( disabled == true )
141             addAttribute("disabled", "disabled");
142         else
143             removeAttribute("disabled");
144             
145         return(this);
146     }
147     
148     /**
149         Sets the lang="" and xml:lang="" attributes
150         @param lang the lang="" and xml:lang="" attributes
151     */

152     public Element setLang(String JavaDoc lang)
153     {
154         addAttribute("lang",lang);
155         addAttribute("xml:lang",lang);
156         return this;
157     }
158
159     /**
160         Adds an Element to the element.
161         @param hashcode name of element for hash table
162         @param element Adds an Element to the element.
163      */

164     public optgroup addElement(String JavaDoc hashcode,Element element)
165     {
166         addElementToRegistry(hashcode,element);
167         return(this);
168     }
169
170     /**
171         Adds an Element to the element.
172         @param hashcode name of element for hash table
173         @param element Adds an Element to the element.
174      */

175     public optgroup addElement(String JavaDoc hashcode,String JavaDoc element)
176     {
177         addElementToRegistry(hashcode,element);
178         return(this);
179     }
180
181     /**
182         Adds an Element to the element.
183         @param element Adds an Element to the element.
184      */

185     public optgroup addElement(Element element)
186     {
187         addElementToRegistry(element);
188         return(this);
189     }
190     
191     /**
192         Adds an Element to the element.
193         @param element Adds an Element to the element.
194      */

195     public optgroup addElement(String JavaDoc element)
196     {
197         addElementToRegistry(element);
198         return(this);
199     }
200     /**
201         Removes an Element from the element.
202         @param hashcode the name of the element to be removed.
203     */

204     public optgroup removeElement(String JavaDoc hashcode)
205     {
206         removeElementFromRegistry(hashcode);
207         return(this);
208     }
209
210     /**
211         The onfocus event occurs when an element receives focus either by the
212         pointing device or by tabbing navigation. This attribute may be used
213         with the following elements: label, input, select, textarea, and
214         button.
215         
216         @param The script
217     */

218     public void setOnFocus(String JavaDoc script)
219     {
220         addAttribute ( "onfocus", script );
221     }
222
223     /**
224         The onblur event occurs when an element loses focus either by the
225         pointing device or by tabbing navigation. It may be used with the same
226         elements as onfocus.
227         
228         @param The script
229     */

230     public void setOnBlur(String JavaDoc script)
231     {
232         addAttribute ( "onblur", script );
233     }
234
235     /**
236         The onsubmit event occurs when a form is submitted. It only applies to
237         the FORM element.
238         
239         @param The script
240     */

241     public void setOnSubmit(String JavaDoc script)
242     {
243         addAttribute ( "onsubmit", script );
244     }
245
246     /**
247         The onreset event occurs when a form is reset. It only applies to the
248         FORM element.
249         
250         @param The script
251     */

252     public void setOnReset(String JavaDoc script)
253     {
254         addAttribute ( "onreset", script );
255     }
256
257     /**
258         The onselect event occurs when a user selects some text in a text
259         field. This attribute may be used with the input and textarea elements.
260         
261         @param The script
262     */

263     public void setOnSelect(String JavaDoc script)
264     {
265         addAttribute ( "onselect", script );
266     }
267
268     /**
269         The onchange event occurs when a control loses the input focus and its
270         value has been modified since gaining focus. This attribute applies to
271         the following elements: input, select, and textarea.
272         
273         @param The script
274     */

275     public void setOnChange(String JavaDoc script)
276     {
277         addAttribute ( "onchange", script );
278     }
279
280     /**
281         The onclick event occurs when the pointing device button is clicked
282         over an element. This attribute may be used with most elements.
283         
284         @param The script
285     */

286     public void setOnClick(String JavaDoc script)
287     {
288         addAttribute ( "onclick", script );
289     }
290     /**
291         The ondblclick event occurs when the pointing device button is double
292         clicked over an element. This attribute may be used with most elements.
293
294         @param The script
295     */

296     public void setOnDblClick(String JavaDoc script)
297     {
298         addAttribute ( "ondblclick", script );
299     }
300     /**
301         The onmousedown event occurs when the pointing device button is pressed
302         over an element. This attribute may be used with most elements.
303
304         @param The script
305     */

306     public void setOnMouseDown(String JavaDoc script)
307     {
308         addAttribute ( "onmousedown", script );
309     }
310     /**
311         The onmouseup event occurs when the pointing device button is released
312         over an element. This attribute may be used with most elements.
313
314         @param The script
315     */

316     public void setOnMouseUp(String JavaDoc script)
317     {
318         addAttribute ( "onmouseup", script );
319     }
320     /**
321         The onmouseover event occurs when the pointing device is moved onto an
322         element. This attribute may be used with most elements.
323
324         @param The script
325     */

326     public void setOnMouseOver(String JavaDoc script)
327     {
328         addAttribute ( "onmouseover", script );
329     }
330     /**
331         The onmousemove event occurs when the pointing device is moved while it
332         is over an element. This attribute may be used with most elements.
333
334         @param The script
335     */

336     public void setOnMouseMove(String JavaDoc script)
337     {
338         addAttribute ( "onmousemove", script );
339     }
340     /**
341         The onmouseout event occurs when the pointing device is moved away from
342         an element. This attribute may be used with most elements.
343
344         @param The script
345     */

346     public void setOnMouseOut(String JavaDoc script)
347     {
348         addAttribute ( "onmouseout", script );
349     }
350
351     /**
352         The onkeypress event occurs when a key is pressed and released over an
353         element. This attribute may be used with most elements.
354         
355         @param The script
356     */

357     public void setOnKeyPress(String JavaDoc script)
358     {
359         addAttribute ( "onkeypress", script );
360     }
361
362     /**
363         The onkeydown event occurs when a key is pressed down over an element.
364         This attribute may be used with most elements.
365         
366         @param The script
367     */

368     public void setOnKeyDown(String JavaDoc script)
369     {
370         addAttribute ( "onkeydown", script );
371     }
372
373     /**
374         The onkeyup event occurs when a key is released over an element. This
375         attribute may be used with most elements.
376         
377         @param The script
378     */

379     public void setOnKeyUp(String JavaDoc script)
380     {
381         addAttribute ( "onkeyup", script );
382     }
383 }
384
Popular Tags