01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.forms;
17:
18: import java.util.Iterator;
19: import java.util.Locale;
20:
21: import javax.servlet.http.HttpServletRequest;
22:
23: import de.odysseus.calyxo.forms.conf.FormConfig;
24:
25: /**
26: * Form interface.
27: * A form encapsulates its configuration and form inputs. A form
28: * can be validated.
29: *
30: * @author Christoph Beck
31: */
32: public interface Form {
33: /**
34: * Get the form's locale.
35: * The locale returned by this method may not be equal
36: * to the locale of the enclosed form configuration. However,
37: * the configuration's locale must be a generalization of the
38: * form's locale.
39: */
40: public Locale getLocale();
41:
42: /**
43: * Get the enclosed form configuration
44: */
45: public FormConfig getFormConfig();
46:
47: /**
48: * Get {@link FormInput} elements
49: */
50: public Iterator getFormInputs();
51:
52: /**
53: * Get form input by name
54: */
55: public FormInput getFormInput(String name);
56:
57: /**
58: * Validate input parameters
59: * @param request the request we process
60: * @param params form input parameters
61: * @return form validation result
62: */
63: public FormResult validate(HttpServletRequest request,
64: FormInputValues params);
65: }
|