Announcement Announcement Module
Collapse
No announcement yet.
Need help:Validation Context / Errors object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help:Validation Context / Errors object

    Hi,
    I've created a ${model}Validator style validator w/ a validate${state} method with (Model model, ValidationContext Context) as parameters and that works fine. However I also need to call a classic Spring Validator from within this one, so I need the Errors object as well... I read in the reference guide that it can accept the Errors object; so I changed the parameters of the method to be like so:
    Code:
    public void validateEmailDetail(EmailDistribution emailDistribution,
    			ValidationContext context, Errors errors) {
         MessageContext messages = context.getMessageContext();
    
         this.classicSpringValidator.validate(emailDistribution, errors);
    
         if (emailDistribution.getDescription() == null) {
    	messages.addMessage(new MessageBuilder().error().source(
    	"description").defaultText("Description is required")
    					.build());
    		}
    	}
    When I add the Errors object as a parameter, the method never gets called and validation doesn't happen.

    What am I doing wrong?
    Thanks,
    Mike

  • #2
    It is either MessageContext, ValidationContext or Errors not a combination....

    Comment

    Working...
    X