From 26c561f41d5a8855efbd24730a1eb036c215a3ea Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Fri, 27 Feb 2009 22:21:04 +0000 Subject: [PATCH] polish --- ...aultValidationFailureMessageResolverFactory.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spring-binding/src/main/java/org/springframework/binding/validation/DefaultValidationFailureMessageResolverFactory.java b/spring-binding/src/main/java/org/springframework/binding/validation/DefaultValidationFailureMessageResolverFactory.java index d28cf6a5..0520cdc6 100644 --- a/spring-binding/src/main/java/org/springframework/binding/validation/DefaultValidationFailureMessageResolverFactory.java +++ b/spring-binding/src/main/java/org/springframework/binding/validation/DefaultValidationFailureMessageResolverFactory.java @@ -34,20 +34,21 @@ import org.springframework.util.Assert; /** * Maps validation failures to messages resolvable in a {@link MessageSource}. Configurable with an - * {@link ExpressionParser} to provide support messages that contain #{expressions} for inserting failure arguments. + * {@link ExpressionParser} to allow messages containing #{expressions} to be parameterized with failure arguments. * Configurable with a {@link ConversionService} to support String-encoding failure arguments. * * Employs the following algorithm to map property validation failure to a message: *
    - *
  1. Try the ${failureMessageCodePrefix}.${objectName}.${propertyName}.${constraint} code; if match, resolve message + *
  2. Try the ${failureMessageCodePrefix}.${objectName}.${propertyName}.${constraint} code; if matches, resolve message * and return. - *
  3. Try the ${failureMessageCodePrefix}.${propertyType}.${constraint} code; if matched, resolve message and return. - *
  4. Try the ${failureMessageCodePrefix}.${constrant} code; if matched, resolve message and return. + *
  5. Try the ${failureMessageCodePrefix}.${propertyType}.${constraint} code; if matches, resolve message and return. + *
  6. Try the ${failureMessageCodePrefix}.${constraint} code; if matches, resolve message and return. *
* * Named message arguments may be denoted by using ${} or #{} expressions. For property validation failures, the value * of the "label" argument is automatically mapped to the message with code - * ${labelMessageCodePrefix}.${objectName}.${propertyName}. + * ${labelMessageCodePrefix}.${objectName}.${propertyName}, allowing localization of the property label. Also, the + * "value" argument holds a reference to the invalid user-entered value that triggered the failure. * * messages.properties example: * @@ -55,8 +56,10 @@ import org.springframework.util.Assert; * validation.booking.checkinDate.required=The Checkin Date is required * validation.java.util.Date.required=Dates are required * validation.required=#{label} is required + * validation.range=#{label} must be between #{min} and #{max} but it was #{value} * * label.booking.checkoutDate=Check Out Date + * label.booking.amount=Amount * * @author Keith Donald */