KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > web > validation > admin > ApplicationValidator


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.web.validation.admin;
21
22 import org.openi.application.Application;
23 import org.springframework.validation.Errors;
24 import org.springframework.validation.ValidationUtils;
25 import org.springframework.validation.Validator;
26
27
28 /**
29  * @author Uddhab Pant <br>
30  * @version $Revision: 1.5 $ $Date: 2006/04/12 00:39:12 $ <br>
31  *
32  * Validates application form.
33  *
34  */

35 public class ApplicationValidator implements Validator {
36     /**
37      * Return whether or not this object can validate objects
38      * of the given class.
39      * @param _class Class
40      * @return boolean
41      */

42     public boolean supports(Class JavaDoc _class) {
43         return Application.class.isAssignableFrom(_class);
44     }
45
46     /**
47      * Validate an object, which must be of a class for which
48      * the supports() method returned true.
49      *
50      * @param object Object
51      * @param errors Errors
52      */

53     public void validate(Object JavaDoc object, Errors errors) {
54         // application title and logon image are required.
55
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "applicationTitle",
56             "required.message");
57         ValidationUtils.rejectIfEmptyOrWhitespace(errors, "logonImageName",
58             "required.message");
59     }
60 }
61
Popular Tags