KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > forms > Element


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  *
23  * ***** END LICENSE BLOCK ***** */

24 package org.riotfamily.forms;
25
26 import java.io.PrintWriter JavaDoc;
27
28 import org.riotfamily.forms.request.FormRequest;
29
30
31
32
33
34 /**
35  * Interface to be implemented by all form elements. If you want to create a
36  * new element you will most likely want to subclass one of the abstract base
37  * classes in the <code>de.neteye.forms.element.support</code> package.
38  */

39 public interface Element {
40     
41     /**
42      * Sets the element's unique id. Ids are assigned when an element is
43      * registered with a form.
44      *
45      * @see Form#registerElement(Element)
46      */

47     public void setId(String JavaDoc id);
48
49     /**
50      * Returns the previously assigned id.
51      */

52     public String JavaDoc getId();
53     
54     /**
55      * Sets a reference to the form that contains the element.
56      */

57     public void setForm(Form form);
58
59     /**
60      * Returns the form that contains the element.
61      */

62     public Form getForm();
63     
64     /**
65      * Sets the FormContext. Invoked by {@link Form#registerElement(Element)}
66      * or {@link Form#setFormContext(FormContext)}.
67      */

68     public void setFormContext(FormContext formContext);
69     
70     /**
71      * Sets the element's parent. E.g. the parent element is taken into account
72      * to determine the enabled state of the element.
73      */

74     public void setParent(Element parent);
75     
76     /**
77      * Returns the element's parent.
78      */

79     public Element getParent();
80     
81     /**
82      * This method is invoked whenever a HTTP request needs to be processed.
83      * Elements may impelement this method to change their internal state
84      * according to parameters found in the request.
85      */

86     public void processRequest(FormRequest request);
87         
88     /**
89      * Renders the element to the given writer.
90      */

91     public void render(PrintWriter JavaDoc writer);
92     
93     /**
94      * Focuses the element.
95      */

96     public void focus();
97     
98     /**
99      * Returns whether the element will accept user input. The state should
100      * be considered during rendering, i.e. disabled elements should look
101      * different than enabled ones.
102      */

103     public boolean isEnabled();
104     
105     /**
106      * Enables (or disables) the element.
107      */

108     public void setEnabled(boolean enabled);
109     
110     /**
111      * Returns whether the element is mandatory and must be filled out by
112      * the user.
113      */

114     public boolean isRequired();
115     
116     /**
117      * Sets whether the element is required.
118      */

119     public void setRequired(boolean required);
120     
121     /**
122      * Returns whether the element is composed of multiple widgets.
123      * The information may be used by templates to render composite elements
124      * in the same style as element groups or nested forms.
125      */

126     public boolean isCompositeElement();
127     
128 }
Popular Tags