01: // ========================================================================
02: // $Id: Input.java,v 1.3 2004/05/09 20:31:28 gregwilkins Exp $
03: // Copyright 1996-2004 Mort Bay Consulting Pty. Ltd.
04: // ------------------------------------------------------------------------
05: // Licensed under the Apache License, Version 2.0 (the "License");
06: // you may not use this file except in compliance with the License.
07: // You may obtain a copy of the License at
08: // http://www.apache.org/licenses/LICENSE-2.0
09: // 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: /** Input types */
29: public final static String Text = "text";
30: public final static String Password = "password";
31: public final static String Checkbox = "checkbox";
32: public final static String Radio = "radio";
33: public final static String Submit = "submit";
34: public final static String Reset = "reset";
35: public final static String Hidden = "hidden";
36: public final static String File = "file";
37: public final static String Image = "image";
38:
39: /* ----------------------------------------------------------------- */
40: public Input(String type, String name) {
41: super ("input");
42: attribute("type", type);
43: attribute("name", name);
44: }
45:
46: /* ----------------------------------------------------------------- */
47: public Input(String type, String name, String value) {
48: this (type, name);
49: attribute("value", value);
50: }
51:
52: /* ----------------------------------------------------------------- */
53: public Input(Image image, String name, String value) {
54: super ("input");
55: attribute("type", "image");
56: attribute("name", name);
57: if (value != null)
58: attribute("value", value);
59: attribute(image.attributes());
60: }
61:
62: /* ----------------------------------------------------------------- */
63: public Input(Image image, String name) {
64: super ("input");
65: attribute("type", "image");
66: attribute("name", name);
67: attribute(image.attributes());
68: }
69:
70: /* ----------------------------------------------------------------- */
71: public Input check() {
72: attribute("checked");
73: return this ;
74: }
75:
76: /* ----------------------------------------------------------------- */
77: public Input setSize(int size) {
78: size(size);
79: return this ;
80: }
81:
82: /* ----------------------------------------------------------------- */
83: public Input setMaxSize(int size) {
84: attribute("maxlength", size);
85: return this ;
86: }
87:
88: /* ----------------------------------------------------------------- */
89: public Input fixed() {
90: setMaxSize(size());
91: return this;
92: }
93: }
|