Announcement Announcement Module
No announcement yet.
Manual data binding in Spring MVC 3.0 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Manual data binding in Spring MVC 3.0

    I've got a use case where the standard data binding and validation provided by Spring MVC 3.x (@Valid @ModelAttribute SomeObject someObject, BindingResult result) isn't sufficient.

    Once I do the manual binding and validation, what I can't figure out how to do is expose the Errors object (or whatever type it is) so that the Spring form tags render validation and binding errors when the form is redisplayed.

    Here's what I have so far:

    ServletRequestDataBinder binder = new ServletRequestDataBinder(target); // target is the command object
    binder.bind(request); // HttpServletRequest
    BindingResult result = binder.getBindingResult();
    validator.validate(target, result);
    As you can see above, I bind the request to the command object and then validate the command object as well.

    How do I get what's in the BindingResult into the model/request context so that the Spring form tags can see it?