chain
目的 Purpose
Uses flash storage to implicitly retain the model following an HTTP redirect from one action to another.使用例 Examples
def shawshankRedemption = new Book(title: 'The Shawshank Redemption') chain(action: "details", model: [book: shawshankRedemption])
詳細 Description
使用方法: Usage:
chain(controller*, action, id*, model, params*)
Arguments:
uri
- The full uri to redirect to (example /book/list, book/show/2)controller
(optional) - The controller to redirect to; defaults to the current controller if not specifiednamespace
(optional) - the namespace of the controller to chain toaction
- The action to redirect to, either a string name or a reference to an action within the current controllerid
(optional) - The id to use in redirectionmodel
- The model to chain to the next actionparams
(optional) - Parameters to pass to the action chained to.
def one() { chain action: 'two', model: [name: 'Tony', town: 'Birmingham'] }def two() { [name: 'Anthony', country: 'England'] }
one
action, that action chains to the two
action which returns a model. The model that is passed to the view would contain [name: 'Anthony', town: 'Birmingham', country: 'England']
The chain method requires either a URI to redirect to or a controller/action/id name combination