1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package nl.openedge.baritus;
32
33 import java.util.Map;
34
35 import org.infohazard.maverick.flow.ControllerContext;
36
37 /***
38 * ValidatorDelegates can do validation on input and populated form beans.
39 * Besides the allways used DefaultValidatorDelegate, users of Baritus
40 * can register additional delegates, for instance to be able to plug in
41 * validator mechanisms like FormProc or Commons Validator.
42 *
43 * @author Eelco Hillenius
44 */
45 interface ValidatorDelegate
46 {
47 /***
48 * handle the validation for all provided parameters. The parameters consist
49 * typically of the request parameters, possibly (depending on the also
50 * provided instance of ExecutionParams) with the addition of Maverick
51 * configuration parameters, session attributes and request attributes.
52 *
53 * Implementers should take care to only use the fields stored in parameters
54 * and not to get the field directly from e.g. the http request.
55 *
56 * The populated form is stored in the formBeanContext. If implementors have
57 * validation errors, they should store the error messages in the instance of
58 * FormBeanContext (using method(s) setError/ setErrors), and they should save
59 * the original input values (as stored in Map parameters) as override values
60 * in the formBeanContext (using method(s) setOverrideField)
61 *
62 * @param cctx controller context
63 * @param formBeanContext form bean context with populated bean
64 * @param execParams execution parameters
65 * @param parameters the map in which the requested values are stored. This
66 * map has at least the request parameters stored and depending on the
67 * execution parameters the maverick configuration parameters, session
68 * attributes and request attributes.
69 * @param succeeded whether population/ validation succeeded so far (did not
70 * generate any errors).
71 * @return whether validation passed
72 *
73 * NOTE: implementors should take note that it is possible that population/
74 * validation allready failed before this method is called (in that case
75 * succeeded is false). If you do not want to override the errors (what
76 * is probably is good idea), you can check the current error map or
77 * overwrite value map in the formBeanContext. This allways works for
78 * properties that failed to populate, though it might not work for
79 * failed validations as that depends on the registrations that the
80 * individual validators make in the error map.
81 */
82 public boolean doValidation(
83 ControllerContext cctx,
84 FormBeanContext formBeanContext,
85 ExecutionParams execParams,
86 Map parameters,
87 boolean succeeded);
88 }