KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > validator > Validator


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.validator;
8
9
10 import java.util.Map JavaDoc;
11
12 import com.inversoft.verge.mvc.controller.Action;
13 import com.inversoft.verge.util.WebBeanProperty;
14
15
16 /**
17  * <p>
18  * This interface describes the generic method of validation
19  * within the default Inversoft MVC implementation. This
20  * validation is based on a conversion handling and validation
21  * scheme. The conversion handling is a method that is called
22  * if an automatic conversion fails for any reason. The
23  * validation is a method that is called to validate the
24  * model.
25  * </p>
26  *
27  * @author Brian Pontarelli
28  * @since 2.0
29  * @version 2.0
30  */

31 public interface Validator {
32
33     /**
34      * <p>
35      * Validates the model object given. If the validation fails, all errors should
36      * be added to the RequestContext object given. This object is a facade on top
37      * of the HttpServletRequest that stores error messages.
38      * </p>
39      *
40      * <p>
41      * The Map passed in contains all the model objects from the request submitted.
42      * These are key off the ids associated with the objects. Most of the model
43      * objects are stored in one of the scopes and generally this id is the key
44      * of the object in that scope.
45      * </p>
46      *
47      * @param modelObjects A Map containing all the Model Objects used on the
48      * form that was submitted
49      * @param action The action taken
50      * @return True if the validate succeeded, false otherwise
51      */

52     boolean validate(Map JavaDoc modelObjects, Action action);
53
54     /**
55      * Handles cases of invalid conversion. Every invalid conversion that occurs,
56      * this method is called once. Therefore, this method may be called multiple
57      * times for a single request.
58      *
59      * @param model The Model Object that the conversion failed for
60      * @param property The WebBeanProperty which was being set when the conversion
61      * failed
62      * @param action The action taken
63      */

64     void handleConversion(Object JavaDoc model, WebBeanProperty property,
65             Action action);
66 }
67
Popular Tags