KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > html > Input


1 // ========================================================================
2
// $Id: Input.java,v 1.3 2004/05/09 20:31:28 gregwilkins Exp $
3
// Copyright 1996-2004 Mort Bay Consulting Pty. Ltd.
4
// ------------------------------------------------------------------------
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// ========================================================================
15

16 package org.mortbay.html;
17
18 /* -------------------------------------------------------------------- */
19 /** HTML Form Input Tag.
20  * <p>
21  * @see Tag
22  * @see Form
23  * @version $Id: Input.java,v 1.3 2004/05/09 20:31:28 gregwilkins Exp $
24  * @author Greg Wilkins
25  */

26 public class Input extends Tag
27 {
28     /* ----------------------------------------------------------------- */
29     /** Input types */
30     public final static String JavaDoc Text="text";
31     public final static String JavaDoc Password="password";
32     public final static String JavaDoc Checkbox="checkbox";
33     public final static String JavaDoc Radio="radio";
34     public final static String JavaDoc Submit="submit";
35     public final static String JavaDoc Reset="reset";
36     public final static String JavaDoc Hidden="hidden";
37     public final static String JavaDoc File="file";
38     public final static String JavaDoc Image="image";
39
40     /* ----------------------------------------------------------------- */
41     public Input(String JavaDoc type,String JavaDoc name)
42     {
43         super("input");
44         attribute("type",type);
45         attribute("name",name);
46     }
47
48     /* ----------------------------------------------------------------- */
49     public Input(String JavaDoc type,String JavaDoc name, String JavaDoc value)
50     {
51         this(type,name);
52         attribute("value",value);
53     }
54
55     /* ----------------------------------------------------------------- */
56     public Input(Image image,String JavaDoc name, String JavaDoc value)
57     {
58         super("input");
59         attribute("type","image");
60         attribute("name",name);
61         if (value!=null)
62             attribute("value",value);
63         attribute(image.attributes());
64     }
65     
66     /* ----------------------------------------------------------------- */
67     public Input(Image image,String JavaDoc name)
68     {
69         super("input");
70         attribute("type","image");
71         attribute("name",name);
72         attribute(image.attributes());
73     }
74
75     /* ----------------------------------------------------------------- */
76     public Input check()
77     {
78         attribute("checked");
79         return this;
80     }
81
82     /* ----------------------------------------------------------------- */
83     public Input setSize(int size)
84     {
85         size(size);
86         return this;
87     }
88
89     /* ----------------------------------------------------------------- */
90     public Input setMaxSize(int size)
91     {
92         attribute("maxlength",size);
93         return this;
94     }
95
96     /* ----------------------------------------------------------------- */
97     public Input fixed()
98     {
99         setMaxSize(size());
100         return this;
101     }
102 }
103
Popular Tags