Search code examples
grailsparametersmodelcontrollerchain

Grails - Controller chain and model disapearance


I am trying to use the chain feature to call an other method and render a merged model. This is how I call the chain:

Controller: emailToNotify, Method: sendEmailConfirmation

if (someCommandObject.hasErrors())
                chain(controller: "creditProvider", action: "rank", model: [emailToNotify: epnc, somethingToDisplay: "Boom !!!!"])

This is how my rank method end-up in my creditProvider controller:

Controller: creditProvider, action: rank

render (view: 'simulateResult', model: [bim : bam, boom : bimbamboom])

I do not manage to call ${emailToNotify} or ${somethingToDisplay} from my simulateResult.gsp view.

I have already used chain before in this exact same way, and it was (and still is) working properly.

Any idea why the model is not passed properly to the view ?

Any help most welcome as always. All the best,


Solution

  • chain only works if the final action returns a Map and not if the final action uses the render call. To get what you are doing to work you'll have to manually merge the implicit variable chainModel with the model you're passing back in to the render.