Announcement Announcement Module
Collapse
No announcement yet.
Binding GET parm to Object (or how to attach bindingresult) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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);
    binder.setValidator(entityValidator);
    // validate the target object
    binder.validate();
    // 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?

    thank you
Working...
X