Richard Fearn

  • Twitter

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • Delicious bookmarks

  • Meta

Passing reference data to the success view

Posted by Richard on 2007/03/17

When using Spring’s SimpleFormController, the default behaviour is to pass reference data to the form view, but not to the success view. However it’s very easy to override this behaviour, and access the reference data from the success view as well.

To do this, override the 4-argument onSubmit method like this:

protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
    ModelAndView mav = onSubmit(command, errors);
    Map refData = referenceData(request, command, errors);
    mav.getModel().putAll(refData);
    return mav;
}

If you’ve only implemented the 1-argument referenceData method, don’t worry; the default 3-argument referenceData just delegates to the 1-argument method, so your implementation will be called.

If you’re interested, you can see the code for SimpleFormController.

2 Responses to “Passing reference data to the success view”

  1. nsrmbo said

    Thanks – just the tip I was looking for!

  2. orx said

    dito ! thx

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>