Jul 19th, 2010, 02:29 PM
Binding GET parm to Object (or how to attach bindingresult)
Still somewhat newish to spring MVC and hopefully this is an easy one but since its not typical I can't find a decent example.
I would like to have a GET request parm BIND to an object and use a bindingresult so that I can validate it just like a post. A little strange but what we are allowing is for the user to save their data with validation errors (as in a draft). I would like upon reopening of the entity to have the validation errors display.
I did do this in the mapped http GET handler method:
DataBinder binder = new DataBinder(entity);
// validate the target object
// get BindingResult that includes any validation errors
BindingResult results = binder.getBindingResult();
SO all validation errors are in the binding result but now how to attach the binding result so that it will be processed by my view? I have not been able to do that.
If I declare bindingresult as a parm to the GET method I get a spring error that no preceding model exists (or some such).
What is the best way to go about achieving this?
Tags for this Thread