KickJava   Java API By Example, From Geeks To Geeks.

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


1 // ========================================================================
2
// $Id: Form.java,v 1.4 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 import java.io.IOException JavaDoc;
18 import java.io.Writer JavaDoc;
19
20 import org.mortbay.http.HttpFields;
21
22 /* -------------------------------------------------------------------- */
23 /** HTML Form.
24  * The specialized Block can contain HTML Form elements as well as
25  * any other HTML elements
26  */

27 public class Form extends Block
28 {
29     public static final String JavaDoc encodingWWWURL = HttpFields.__WwwFormUrlEncode;
30     public static final String JavaDoc encodingMultipartForm = "multipart/form-data";
31     private String JavaDoc method="POST";
32     
33     /* ----------------------------------------------------------------- */
34     /** Constructor.
35      */

36     public Form()
37     {
38         super("form");
39     }
40
41     /* ----------------------------------------------------------------- */
42     /** Constructor.
43      * @param submitURL The URL to submit the form to
44      */

45     public Form(String JavaDoc submitURL)
46     {
47         super("form");
48         action(submitURL);
49     }
50
51     /* ----------------------------------------------------------------- */
52     /** Constructor.
53      * @param submitURL The URL to submit the form to
54      */

55     public Form action(String JavaDoc submitURL)
56     {
57         attribute("action",submitURL);
58         return this;
59     }
60     
61     /* ----------------------------------------------------------------- */
62     /** Set the form target.
63      */

64     public Form target(String JavaDoc t)
65     {
66         attribute("target",t);
67         return this;
68     }
69     
70     /* ----------------------------------------------------------------- */
71     /** Set the form method.
72      */

73     public Form method(String JavaDoc m)
74     {
75         method=m;
76         return this;
77     }
78     
79     /* ------------------------------------------------------------ */
80     /** Set the form encoding type.
81      */

82     public Form encoding(String JavaDoc encoding){
83         attribute("enctype", encoding);
84         return this;
85     }
86     /* ----------------------------------------------------------------- */
87     public void write(Writer JavaDoc out)
88          throws IOException JavaDoc
89     {
90         attribute("method",method);
91         super.write(out);
92     }
93 }
94
95
96
97
98
Popular Tags