I’m building an application that among other things allows users to upload documents. I have the basic create/view actions working just fine, but i’d like to reuse this action in other places.
I want to know if anyone has a pointer for how to do this. There doesn’t seem to be a very good way of doing this.
Here are a few ways i’ve considered:
- Try to do a chain(). This doesn’t work since chaining does a GET, and to upload you need a POST.
- Break out the main business logic into the Grails “service”, and make two actions that use the same code.
- Use a JS modal window. I’ve been thinking a modal that contains an iframe to an “unskinned” version of the document upload. The trick here is to get the window to close when the upload is done.
Thanks
–Matthias
I don’t care for the extending controller method. In fact, I avoid inheritance when possible. I’d rather put the common code in a service class and reuse it that way.