KickJava   Java API By Example, From Geeks To Geeks.

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


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     This class creates a &lt;button&gt; tag.
63                                    
64     @version $Id: button.java,v 1.2 2003/04/27 09:40:57 rdonkin Exp $
65     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
66     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
67     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
68 */

69
70 public class button extends MultiPartElement implements Printable, FocusEvents, MouseEvents, KeyEvents
71 {
72     // convience variables
73
public final static String JavaDoc reset = "reset";
74     public final static String JavaDoc submit = "submit";
75     public final static String JavaDoc button = "button";
76
77     /**
78         private initializaer.
79     */

80     {
81         setElementType("button");
82         setCase(LOWERCASE);
83         setAttributeQuote(true);
84     }
85
86     public button()
87     {
88     }
89
90     /**
91         Set the name of this button.
92         @param name set the name of this button.
93     */

94     public button setName(String JavaDoc name)
95     {
96         addAttribute("name",name);
97         return(this);
98     }
99
100     /**
101         Set the value of this button.
102         @param value set the value of this button.
103     */

104     public button setValue(String JavaDoc value)
105     {
106         addAttribute("value",value);
107         return(this);
108     }
109
110     /**
111         Set the type of button this is. Convience variables are<br>
112         button.submit<br>button.reset<br>button.button
113         @param button type.
114     */

115     public button setType(String JavaDoc type)
116     {
117         addAttribute("type",type);
118         return(this);
119     }
120
121     /**
122         Is this button disabled?
123         disabled true|false
124     */

125     public button setDisabled(boolean disabled)
126     {
127         if(disabled)
128             addAttribute("disabled","disabled");
129         else
130             removeAttribute("disabled");
131         return(this);
132     }
133
134     /**
135         Set the elements position in the tabbing order.
136         @param number set the elements position in the tabbing order.
137     */

138     public button setTabIndex(int number)
139     {
140         addAttribute("tabindex",Integer.toString(number));
141         return(this);
142     }
143
144     /**
145         Set the elements position in the tabbing order.
146         @param number set the elements position in the tabbing order.
147     */

148     public button setTabIndex(String JavaDoc number)
149     {
150         addAttribute("tabindex",number);
151         return(this);
152     }
153
154     /**
155         Sets the lang="" and xml:lang="" attributes
156         @param lang the lang="" and xml:lang="" attributes
157     */

158     public Element setLang(String JavaDoc lang)
159     {
160         addAttribute("lang",lang);
161         addAttribute("xml:lang",lang);
162         return this;
163     }
164
165     /**
166         Adds an Element to the element.
167         @param hashcode name of element for hash table
168         @param element Adds an Element to the element.
169      */

170     public button addElement(String JavaDoc hashcode,Element element)
171     {
172         addElementToRegistry(hashcode,element);
173         return(this);
174     }
175
176     /**
177         Adds an Element to the element.
178         @param hashcode name of element for hash table
179         @param element Adds an Element to the element.
180      */

181     public button addElement(String JavaDoc hashcode,String JavaDoc element)
182     {
183         addElementToRegistry(hashcode,element);
184         return(this);
185     }
186
187     /**
188         Adds an Element to the element.
189         @param element Adds an Element to the element.
190      */

191     public button addElement(Element element)
192     {
193         addElementToRegistry(element);
194         return(this);
195     }
196     
197     /**
198         Adds an Element to the element.
199         @param element Adds an Element to the element.
200      */

201     public button addElement(String JavaDoc element)
202     {
203         addElementToRegistry(element);
204         return(this);
205     }
206     /**
207         Removes an Element from the element.
208         @param hashcode the name of the element to be removed.
209     */

210     public button removeElement(String JavaDoc hashcode)
211     {
212         removeElementFromRegistry(hashcode);
213         return(this);
214     }
215
216     /**
217         The onfocus event occurs when an element receives focus either by the
218         pointing device or by tabbing navigation. This attribute may be used
219         with the following elements: LABEL, INPUT, SELECT, TEXTAREA, and
220         BUTTON.
221         
222         @param The script
223     */

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

236     public void setOnBlur(String JavaDoc script)
237     {
238         addAttribute ( "onblur", script );
239     }
240
241     /**
242         The onclick event occurs when the pointing device button is clicked
243         over an element. This attribute may be used with most elements.
244         
245         @param The script
246     */

247     public void setOnClick(String JavaDoc script)
248     {
249         addAttribute ( "onclick", script );
250     }
251     /**
252         The ondblclick event occurs when the pointing device button is double
253         clicked over an element. This attribute may be used with most elements.
254
255         @param The script
256     */

257     public void setOnDblClick(String JavaDoc script)
258     {
259         addAttribute ( "ondblclick", script );
260     }
261     /**
262         The onmousedown event occurs when the pointing device button is pressed
263         over an element. This attribute may be used with most elements.
264
265         @param The script
266     */

267     public void setOnMouseDown(String JavaDoc script)
268     {
269         addAttribute ( "onmousedown", script );
270     }
271     /**
272         The onmouseup event occurs when the pointing device button is released
273         over an element. This attribute may be used with most elements.
274
275         @param The script
276     */

277     public void setOnMouseUp(String JavaDoc script)
278     {
279         addAttribute ( "onmouseup", script );
280     }
281     /**
282         The onmouseover event occurs when the pointing device is moved onto an
283         element. This attribute may be used with most elements.
284
285         @param The script
286     */

287     public void setOnMouseOver(String JavaDoc script)
288     {
289         addAttribute ( "onmouseover", script );
290     }
291     /**
292         The onmousemove event occurs when the pointing device is moved while it
293         is over an element. This attribute may be used with most elements.
294
295         @param The script
296     */

297     public void setOnMouseMove(String JavaDoc script)
298     {
299         addAttribute ( "onmousemove", script );
300     }
301     /**
302         The onmouseout event occurs when the pointing device is moved away from
303         an element. This attribute may be used with most elements.
304
305         @param The script
306     */

307     public void setOnMouseOut(String JavaDoc script)
308     {
309         addAttribute ( "onmouseout", script );
310     }
311
312     /**
313         The onkeypress event occurs when a key is pressed and released over an
314         element. This attribute may be used with most elements.
315         
316         @param The script
317     */

318     public void setOnKeyPress(String JavaDoc script)
319     {
320         addAttribute ( "onkeypress", script );
321     }
322
323     /**
324         The onkeydown event occurs when a key is pressed down over an element.
325         This attribute may be used with most elements.
326         
327         @param The script
328     */

329     public void setOnKeyDown(String JavaDoc script)
330     {
331         addAttribute ( "onkeydown", script );
332     }
333
334     /**
335         The onkeyup event occurs when a key is released over an element. This
336         attribute may be used with most elements.
337         
338         @param The script
339     */

340     public void setOnKeyUp(String JavaDoc script)
341     {
342         addAttribute ( "onkeyup", script );
343     }
344 }
345
Popular Tags