⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enterhoursvalidator.java

📁 Java 敏捷开发--使用Spring Hibernate 和 Eclipse源码
💻 JAVA
字号:
package com.visualpatterns.timex.controller;

import org.springframework.validation.Errors;
import com.visualpatterns.timex.model.Timesheet;

/**
 * Validator for EnterHoursController
 * @author anil
 * @see com.visualpatterns.timex.controller.EnterHoursController
 */
public class EnterHoursValidator implements
        org.springframework.validation.Validator
{
    public boolean supports(Class clazz)
    {
        return clazz.equals(Timesheet.class);
    }

    /**
     * Validates the Timesheet command object.  Ensures that the
     * departmentCode is specified.
     * @see Timesheet 
     */
    public void validate(Object command, Errors errors)
    {
        Timesheet timesheet = (Timesheet) command;
        if (timesheet == null) return;

        if (timesheet.getDepartmentCode() == null
                || timesheet.getDepartmentCode().trim().length() < 1)
            errors.reject("error.enterhours.missingdepartment");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -