Hi,
I eventually figured out a way to do it, I was actually about 90% of the way there already.
Code:
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String validateAndShowRecord(@PathVariable String id, ModelMap map)
//Get form object using request param from querystring
BackingForm form = formService.findForm(id);
//Validate the form, passing in new errors object
BindingResult errors = new BeanPropertyBindingResult(form, "command");
validationService.checkErrors(form, errors);
//Add errors and form objects to map
map.put(BindingResult.MODEL_KEY_PREFIX + "command", errors);
map.put("command", form);
return viewName
The bit that was tripping me up were the following lines
Code:
BindingResult errors = new BeanPropertyBindingResult(form, "command");
map.put(BindingResult.MODEL_KEY_PREFIX + "command", errors);
Once I put these in I was able to add the errors object to my model and it was picked up by my view
Euan