I am trying to work out a way to provide a CSV download through a Spring 3 Portlet. I have a method that uses the @ResourceMapping
annotation to define a handler that takes some report params in the form of a @ModelAttribute
, builds the report, and returns it. The catch-22 I am running into is validating the parameters being send in from the client form.
If I make the handler a @ResourceMapping
, I can set the headers and write out the report as using the ResourceResponse
, but I can't seem to figure out how to redirect the user back to the Portlet view with errors when their input fails validation. However, if I make it an @ActionMapping
, I can then check the BindingResult
s and forward them back to the form as needed, but the ActionResponse
doesn't allow me to set the Content-Disposition header nor write out the CSV bytes, which is sort of critical for sending the report back.
I am at a total loss here, as I don't even know what my options are. Is it even possible to do what I am trying to do with a Portlet? Are there other examples I could look at for a possible work-around?