Java Code Examples for org.springframework.web.bind.WebDataBinder#setValidator()

The following examples show how to use org.springframework.web.bind.WebDataBinder#setValidator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurableWebBindingInitializer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initBinder(WebDataBinder binder, WebRequest request) {
	binder.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
	if (this.directFieldAccess) {
		binder.initDirectFieldAccess();
	}
	if (this.messageCodesResolver != null) {
		binder.setMessageCodesResolver(this.messageCodesResolver);
	}
	if (this.bindingErrorProcessor != null) {
		binder.setBindingErrorProcessor(this.bindingErrorProcessor);
	}
	if (this.validator != null && binder.getTarget() != null &&
			this.validator.supports(binder.getTarget().getClass())) {
		binder.setValidator(this.validator);
	}
	if (this.conversionService != null) {
		binder.setConversionService(this.conversionService);
	}
	if (this.propertyEditorRegistrars != null) {
		for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
			propertyEditorRegistrar.registerCustomEditors(binder);
		}
	}
}
 
Example 2
Source File: RequestResponseBodyMethodProcessorMockTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public WebDataBinder createBinder(NativeWebRequest webRequest, @Nullable Object target,
		String objectName) throws Exception {

	LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
	validator.afterPropertiesSet();
	WebDataBinder dataBinder = new WebDataBinder(target, objectName);
	dataBinder.setValidator(validator);
	return dataBinder;
}
 
Example 3
Source File: RequestPartMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public WebDataBinder createBinder(NativeWebRequest webRequest, @Nullable Object target,
		String objectName) throws Exception {

	LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
	validator.afterPropertiesSet();
	WebDataBinder dataBinder = new WebDataBinder(target, objectName);
	dataBinder.setValidator(validator);
	return dataBinder;
}
 
Example 4
Source File: HttpEntityMethodProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public WebDataBinder createBinder(NativeWebRequest webRequest, @Nullable Object target, String objectName) {
	LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
	validator.afterPropertiesSet();
	WebDataBinder dataBinder = new WebDataBinder(target, objectName);
	dataBinder.setValidator(validator);
	return dataBinder;
}
 
Example 5
Source File: ServletAnnotationControllerHandlerMethodTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@InitBinder({"myCommand", "date"})
public void initBinder(WebDataBinder binder, String date, @RequestParam("date") String[] date2) {
	LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean();
	vf.afterPropertiesSet();
	binder.setValidator(vf);
	assertEquals("2007-10-02", date);
	assertEquals(1, date2.length);
	assertEquals("2007-10-02", date2[0]);
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	dateFormat.setLenient(false);
	binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}
 
Example 6
Source File: PersonalUpdateController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
@InitBinder("personForm")
public void initBinder(WebDataBinder binder){
	binder.setValidator(personalValidator);
    binder.registerCustomEditor(Integer.class, "biography.age", new AgeConverter());	
    binder.registerCustomEditor(Integer.class, "education.year", new YearConverter());	
    binder.registerCustomEditor(Date.class, "biography.birthDate", new BirthDateConverter());	
}
 
Example 7
Source File: ServletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
@InitBinder
private void initBinder(WebDataBinder binder) {
	binder.initBeanPropertyAccess();
	binder.setRequiredFields("sex");
	LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean();
	vf.afterPropertiesSet();
	binder.setValidator(vf);
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	dateFormat.setLenient(false);
	binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}
 
Example 8
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.initDirectFieldAccess();
	binder.setConversionService(new DefaultFormattingConversionService());
	LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean();
	vf.afterPropertiesSet();
	binder.setValidator(vf);
}
 
Example 9
Source File: PersonalUpdateController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
@InitBinder("personForm")
public void initBinder(WebDataBinder binder) {
	binder.setValidator(personalValidator);
	binder.registerCustomEditor(Integer.class, "biography.age",
			new AgeConverter());
	binder.registerCustomEditor(Integer.class, "education.year",
			new YearConverter());
	binder.registerCustomEditor(Date.class, "biography.birthDate",
			new BirthDateConverter());
}
 
Example 10
Source File: CustomController.java    From JuniperBot with GNU General Public License v3.0 4 votes vote down vote up
@InitBinder
public void init(WebDataBinder binder) {
    binder.setValidator(validator);
}
 
Example 11
Source File: ProfessionalUpdateController.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@InitBinder("professionalForm")
public void initBinder(WebDataBinder binder){
	binder.setValidator(professionalValidator);
	binder.registerCustomEditor(Integer.class, "years", new YearConverter());	
}
 
Example 12
Source File: LoginController.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@InitBinder("loginForm")
public void initBinder(WebDataBinder binder){
	binder.setValidator(loginValidator);
}
 
Example 13
Source File: ProductController.java    From maven-framework-project with MIT License 4 votes vote down vote up
@InitBinder
public void initialiseBinder(WebDataBinder binder) {
	binder.setValidator(productValidator);
	binder.setAllowedFields("productId","name","unitPrice","description","manufacturer","category","unitsInStock", "condition","productImage","language");
}
 
Example 14
Source File: RemoteCatalogServiceController.java    From tds with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@InitBinder("remoteCatalogRequest")
protected void initRemoteCatalogRequestBinder(WebDataBinder binder) {
  binder.setValidator(new RemoteCatalogRequestValidator());
}
 
Example 15
Source File: IndexUpdateController.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@InitBinder("homeForm")
public void initBinder(WebDataBinder binder){
	binder.setValidator(indexValidator);
}
 
Example 16
Source File: IndexUpdateController.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@InitBinder("homeForm")
public void initBinder(WebDataBinder binder) {
	binder.setValidator(indexValidator);
}
 
Example 17
Source File: RetailCustomerController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 4 votes vote down vote up
@InitBinder
protected void initBinder(WebDataBinder binder) {
	binder.setValidator(new RetailCustomerValidator());
}
 
Example 18
Source File: ProductController.java    From maven-framework-project with MIT License 4 votes vote down vote up
@InitBinder
public void initialiseBinder(WebDataBinder binder) {
	binder.setValidator(productValidator);
	binder.setAllowedFields("productId","name","unitPrice","description","manufacturer","category","unitsInStock", "condition","productImage","language");
}
 
Example 19
Source File: TestObjectController.java    From etf-webapp with European Union Public License 1.2 4 votes vote down vote up
@InitBinder
private void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.zzz");
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    binder.setValidator(new TObjectValidator());
}
 
Example 20
Source File: ProductController.java    From maven-framework-project with MIT License 4 votes vote down vote up
@InitBinder
public void initialiseBinder(WebDataBinder binder) {
	binder.setValidator(productValidator);
	binder.setAllowedFields("productId","name","unitPrice","description","manufacturer","category","unitsInStock", "condition","productImage","language");
}