Package com.vst.webapp.validators

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

package com.vst.webapp.validators;

import com.vst.model.Thickness;
import com.vst.service.ThicknessManager;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
* Created by IntelliJ IDEA.
* User: And Lilia
* Date: 13.05.2009
* Time: 17:19:37
* To change this template use File | Settings | File Templates.
*/
public class ThicknessValidator implements Validator {
    ThicknessManager thicknessManager;

    public void setThicknessManager(ThicknessManager thicknessManager) {
        this.thicknessManager = thicknessManager;
    }

    public boolean supports(Class aClass) {
        return Thickness.class.isAssignableFrom(aClass)//To change body of implemented methods use File | Settings | File Templates.
    }

    public void validate(Object o, Errors errors) {
        Thickness thickness=(Thickness)o;
        if (thickness.getThicknessCount()==null){
            errors.rejectValue("thicknessCount","thicknessCount.error");
        }else{
            if (thicknessManager.exist(thickness) && thickness.getThicknessId()==null){
                errors.rejectValue("thicknessId","thickness.error");
            }
        }
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
TOP

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

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.