Example usage for org.springframework.web.bind WebDataBinder addValidators

List of usage examples for org.springframework.web.bind WebDataBinder addValidators

Introduction

In this page you can find the example usage for org.springframework.web.bind WebDataBinder addValidators.

Prototype

public void addValidators(Validator... validators) 

Source Link

Document

Add Validators to apply after each binding step.

Usage

From source file:cz.muni.fi.dndtroopsweb.controllers.TroopController.java

/**
 * Binds validator for Troop creation//w w  w . ja  v a 2  s  .  co m
 */
@InitBinder
protected void initBinder(WebDataBinder binder) {
    if (binder.getTarget() instanceof TroopCreateDTO) {
        binder.addValidators(new TroopCreateDTOValidator());
    }
}

From source file:cz.muni.fi.pa165.mvc.controllers.PlayerController.java

@InitBinder
protected void initBinder(WebDataBinder binder) {
    if (binder.getTarget() instanceof PlayerCreateDTO) {
        binder.addValidators(new PlayerCreateDTOValidator());
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
        sdf.setLenient(true);/* w w  w. ja  v a  2s.co m*/
        binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
    }
}

From source file:cz.muni.fi.dndtroopsweb.controllers.HeroController.java

/**
 * Binds validator for Hero creation//from  w  w w .j av a  2 s.c  om
 */
@InitBinder
protected void initBinder(WebDataBinder binder) {
    if (binder.getTarget() instanceof HeroCreateDTO) {
        binder.addValidators(new HeroCreateDTOValidator());
    }
}

From source file:vn.jv.web.controller.UserDashboardController.java

@InitBinder("profileForm")
protected void initProfileBinder(WebDataBinder binder) {
    binder.addValidators(new ProfileFormValidator());
}

From source file:cz.muni.fi.mvc.controllers.StewardController.java

@InitBinder
protected void initBinder(WebDataBinder binder) {
    CustomDateFormater dateFormat = new CustomDateFormater("yyyy-MM-dd");
    dateFormat.setLenient(false);/*from   w  w  w .j a v  a 2s  . c  o m*/
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    if (binder.getTarget() instanceof StewardCreationalDTO) {
        binder.addValidators(new StewardCreationalDTOValidator(stewardFacade));
    }

    if (binder.getTarget() instanceof UpdateStewardDTO) {
        binder.addValidators(new StewardUpdateDTOValidator(stewardFacade));
    }
}