Search in sources :

Example 1 with MessageCodesResolver

use of org.springframework.validation.MessageCodesResolver in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method getConfigurableWebBindingInitializer.

/**
 * Return the {@link ConfigurableWebBindingInitializer} to use for
 * initializing all {@link WebDataBinder} instances.
 */
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer(FormattingConversionService webFluxConversionService, Validator webFluxValidator) {
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setConversionService(webFluxConversionService);
    initializer.setValidator(webFluxValidator);
    MessageCodesResolver messageCodesResolver = getMessageCodesResolver();
    if (messageCodesResolver != null) {
        initializer.setMessageCodesResolver(messageCodesResolver);
    }
    return initializer;
}
Also used : ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) MessageCodesResolver(org.springframework.validation.MessageCodesResolver)

Example 2 with MessageCodesResolver

use of org.springframework.validation.MessageCodesResolver in project spring-framework by spring-projects.

the class TestPathHelper method testMessageCodesResolver.

@Test
public void testMessageCodesResolver() {
    loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
    RequestMappingHandlerAdapter adapter = this.appContext.getBean(RequestMappingHandlerAdapter.class);
    assertThat(adapter).isNotNull();
    Object initializer = adapter.getWebBindingInitializer();
    assertThat(initializer).isNotNull();
    MessageCodesResolver resolver = ((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver();
    assertThat(resolver).isNotNull();
    assertThat(resolver.getClass()).isEqualTo(TestMessageCodesResolver.class);
    assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse();
}
Also used : ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) RequestMappingHandlerAdapter(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter) MessageCodesResolver(org.springframework.validation.MessageCodesResolver) Test(org.junit.jupiter.api.Test)

Example 3 with MessageCodesResolver

use of org.springframework.validation.MessageCodesResolver in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method getConfigurableWebBindingInitializer.

/**
 * Return the {@link ConfigurableWebBindingInitializer} to use for
 * initializing all {@link WebDataBinder} instances.
 */
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer(FormattingConversionService mvcConversionService, Validator mvcValidator) {
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setConversionService(mvcConversionService);
    initializer.setValidator(mvcValidator);
    MessageCodesResolver messageCodesResolver = getMessageCodesResolver();
    if (messageCodesResolver != null) {
        initializer.setMessageCodesResolver(messageCodesResolver);
    }
    return initializer;
}
Also used : ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) MessageCodesResolver(org.springframework.validation.MessageCodesResolver)

Aggregations

MessageCodesResolver (org.springframework.validation.MessageCodesResolver)3 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)3 Test (org.junit.jupiter.api.Test)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)1