Package com.vst.webapp.validators

Source Code of com.vst.webapp.validators.GostValidator

package com.vst.webapp.validators;

import com.vst.model.Gost;
import com.vst.service.GostManager;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
* Created by IntelliJ IDEA.
* User: And Lilia
* Date: 15.04.2009
* Time: 16:42:37
* To change this template use File | Settings | File Templates.
*/
public class GostValidator implements Validator {

    GostManager gostManager;

    public void setGostManager(GostManager gostManager) {
        this.gostManager = gostManager;
    }

    public boolean supports(Class aClass) {
        return Gost.class.isAssignableFrom(aClass);
    }

    public void validate(Object o, Errors errors) {
       Gost gost=(Gost)o;

        if (gost==null || gost.getGostName().trim().equals("") || gost.getGostAbout().trim().equals("")){
            if (gost==null || gost.getGostAbout().trim().equals("")) {
                errors.rejectValue("gostAbout","insert.gostAbouterror");
            }
            if (gost==null || gost.getGostName().trim().equals("") ){
                errors.rejectValue("gostName", "gost.nullerror");
            }
          
        }else
            {
                if (gostManager.isGostExist(gost) && gost.getGostId()==null){
               errors.rejectValue("gostName", "gost.existerror");
            }
        }

    }
}
TOP

Related Classes of com.vst.webapp.validators.GostValidator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.