Java Code Examples for org.springframework.validation.MessageCodesResolver

The following examples show how to use org.springframework.validation.MessageCodesResolver. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: WebMvcConfigurerComposite.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
	MessageCodesResolver selected = null;
	for (WebMvcConfigurer configurer : this.delegates) {
		MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();
		if (messageCodesResolver != null) {
			if (selected != null) {
				throw new IllegalStateException("No unique MessageCodesResolver found: {" +
						selected + ", " + messageCodesResolver + "}");
			}
			selected = messageCodesResolver;
		}
	}
	return selected;
}
 
Example 2
Source Project: java-technology-stack   Source File: WebMvcConfigurerComposite.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
	MessageCodesResolver selected = null;
	for (WebMvcConfigurer configurer : this.delegates) {
		MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();
		if (messageCodesResolver != null) {
			if (selected != null) {
				throw new IllegalStateException("No unique MessageCodesResolver found: {" +
						selected + ", " + messageCodesResolver + "}");
			}
			selected = messageCodesResolver;
		}
	}
	return selected;
}
 
Example 3
Source Project: spring-analysis-note   Source File: WebFluxConfigurationSupport.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source Project: spring-analysis-note   Source File: WebMvcConfigurationSupport.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
@SuppressWarnings("serial")
@Override
public MessageCodesResolver getMessageCodesResolver() {
	return new DefaultMessageCodesResolver() {
		@Override
		public String[] resolveMessageCodes(String errorCode, String objectName) {
			return new String[] {"custom." + errorCode};
		}
	};
}
 
Example 6
@Test
public void testMessageCodesResolver() {
	loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
	RequestMappingHandlerAdapter adapter = this.appContext.getBean(RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);
	Object initializer = adapter.getWebBindingInitializer();
	assertNotNull(initializer);
	MessageCodesResolver resolver =
			((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver();
	assertNotNull(resolver);
	assertEquals(TestMessageCodesResolver.class, resolver.getClass());
	assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));
}
 
Example 7
/**
 * Return the {@link ConfigurableWebBindingInitializer} to use for
 * initializing all {@link WebDataBinder} instances.
 */
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() {
	ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
	initializer.setConversionService(webFluxConversionService());
	initializer.setValidator(webFluxValidator());
	MessageCodesResolver messageCodesResolver = getMessageCodesResolver();
	if (messageCodesResolver != null) {
		initializer.setMessageCodesResolver(messageCodesResolver);
	}
	return initializer;
}
 
Example 8
Source Project: java-technology-stack   Source File: WebMvcConfigurationSupport.java    License: MIT License 5 votes vote down vote up
/**
 * Return the {@link ConfigurableWebBindingInitializer} to use for
 * initializing all {@link WebDataBinder} instances.
 */
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() {
	ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
	initializer.setConversionService(mvcConversionService());
	initializer.setValidator(mvcValidator());
	MessageCodesResolver messageCodesResolver = getMessageCodesResolver();
	if (messageCodesResolver != null) {
		initializer.setMessageCodesResolver(messageCodesResolver);
	}
	return initializer;
}
 
Example 9
@SuppressWarnings("serial")
@Override
public MessageCodesResolver getMessageCodesResolver() {
	return new DefaultMessageCodesResolver() {
		@Override
		public String[] resolveMessageCodes(String errorCode, String objectName) {
			return new String[] { "custom." + errorCode };
		}
	};
}
 
Example 10
@Test
public void testMessageCodesResolver() {
	loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
	RequestMappingHandlerAdapter adapter = this.appContext.getBean(RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);
	Object initializer = adapter.getWebBindingInitializer();
	assertNotNull(initializer);
	MessageCodesResolver resolver =
			((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver();
	assertNotNull(resolver);
	assertEquals(TestMessageCodesResolver.class, resolver.getClass());
	assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));
}
 
Example 11
@Override
public MessageCodesResolver getMessageCodesResolver() {
	MessageCodesResolver selected = null;
	for (WebMvcConfigurer configurer : this.delegates) {
		MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();
		if (messageCodesResolver != null) {
			if (selected != null) {
				throw new IllegalStateException("No unique MessageCodesResolver found: {" +
						selected + ", " + messageCodesResolver + "}");
			}
			selected = messageCodesResolver;
		}
	}
	return selected;
}
 
Example 12
@Override
public MessageCodesResolver getMessageCodesResolver() {
	List<MessageCodesResolver> candidates = new ArrayList<MessageCodesResolver>();
	for (WebMvcConfigurer configurer : this.delegates) {
		MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();
		if (messageCodesResolver != null) {
			candidates.add(messageCodesResolver);
		}
	}
	return selectSingleInstance(candidates, MessageCodesResolver.class);
}
 
Example 13
@SuppressWarnings("serial")
@Override
public MessageCodesResolver getMessageCodesResolver() {
	return new DefaultMessageCodesResolver() {
		@Override
		public String[] resolveMessageCodes(String errorCode, String objectName) {
			return new String[] { "custom." + errorCode };
		}
	};
}
 
Example 14
@Test
public void testMessageCodesResolver() {
	loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
	RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);
	Object initializer = adapter.getWebBindingInitializer();
	assertNotNull(initializer);
	MessageCodesResolver resolver = ((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver();
	assertNotNull(resolver);
	assertEquals(TestMessageCodesResolver.class, resolver.getClass());
	assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));
}
 
Example 15
Source Project: spring-analysis-note   Source File: WebFluxConfigurerComposite.java    License: MIT License 4 votes vote down vote up
@Override
public MessageCodesResolver getMessageCodesResolver() {
	return createSingleBean(WebFluxConfigurer::getMessageCodesResolver, MessageCodesResolver.class);
}
 
Example 16
Source Project: spring-analysis-note   Source File: WebFluxConfigurationSupport.java    License: MIT License 4 votes vote down vote up
/**
 * Override this method to provide a custom {@link MessageCodesResolver}.
 */
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
	return null;
}
 
Example 17
@Override
protected MessageCodesResolver getMessageCodesResolver() {
	MessageCodesResolver messageCodesResolver = this.configurers.getMessageCodesResolver();
	return (messageCodesResolver != null ? messageCodesResolver : super.getMessageCodesResolver());
}
 
Example 18
Source Project: spring-analysis-note   Source File: WebMvcConfigurationSupport.java    License: MIT License 4 votes vote down vote up
/**
 * Override this method to provide a custom {@link MessageCodesResolver}.
 */
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
	return null;
}
 
Example 19
Source Project: spring-analysis-note   Source File: WebMvcConfigurerAdapter.java    License: MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>This implementation returns {@code null}.
 */
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
	return null;
}
 
Example 20
@Override
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
	return this.configurers.getMessageCodesResolver();
}
 
Example 21
/**
 * Return the strategy to use for resolving errors into message codes.
 */
@Nullable
public final MessageCodesResolver getMessageCodesResolver() {
	return this.messageCodesResolver;
}
 
Example 22
@Override
public MessageCodesResolver getMessageCodesResolver() {
    return null;
}
 
Example 23
Source Project: java-technology-stack   Source File: WebFluxConfigurerComposite.java    License: MIT License 4 votes vote down vote up
@Override
public MessageCodesResolver getMessageCodesResolver() {
	return createSingleBean(WebFluxConfigurer::getMessageCodesResolver, MessageCodesResolver.class);
}
 
Example 24
/**
 * Override this method to provide a custom {@link MessageCodesResolver}.
 */
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
	return null;
}
 
Example 25
@Override
protected MessageCodesResolver getMessageCodesResolver() {
	MessageCodesResolver messageCodesResolver = this.configurers.getMessageCodesResolver();
	return (messageCodesResolver != null ? messageCodesResolver : super.getMessageCodesResolver());
}
 
Example 26
Source Project: java-technology-stack   Source File: WebMvcConfigurationSupport.java    License: MIT License 4 votes vote down vote up
/**
 * Override this method to provide a custom {@link MessageCodesResolver}.
 */
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
	return null;
}
 
Example 27
Source Project: java-technology-stack   Source File: WebMvcConfigurerAdapter.java    License: MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>This implementation returns {@code null}.
 */
@Override
@Nullable
public MessageCodesResolver getMessageCodesResolver() {
	return null;
}
 
Example 28
@Override
@Nullable
protected MessageCodesResolver getMessageCodesResolver() {
	return this.configurers.getMessageCodesResolver();
}
 
Example 29
/**
 * Return the strategy to use for resolving errors into message codes.
 */
@Nullable
public final MessageCodesResolver getMessageCodesResolver() {
	return this.messageCodesResolver;
}
 
Example 30
Source Project: jfilter   Source File: FilterRegister.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MessageCodesResolver getMessageCodesResolver() {
    return null;
}