A question came up on the Grails mailing list recently regarding how to pass model data from one action to another.
The solution is to make use of chain() and the chainModel map. As the doco says:
This dynamic property only exists in actions following the call to the chain method…
Here’s a trivial Grails controller class that illustrates How To Do It:
package bob
class TestController {
def index = {
chain(action:'doIt', model:[data:new Data(when:new Date(), what:"Hello, world")])
}
def doIt = {
render chainModel.data.what
}
}
class Data {
Date when
String what
}
I’ve used chain() several times before, but it’s been good to refresh my understanding of chainModel.
