How to get show.gsp param and pass it to another controller

154 views Asked by At

I am try to do something like this Get(param.id) in Controller.show() and forward/redirect(I am not sure) to another controller.

Here's the question, how can I manage to capture the selected (show.gsp)'s param (example:taskName), and "send" it out to another controller.

EDIT 1

I had figure out how to capture

def taskName = Task.get(params.id)

May I know how to "send" out "taskName"

Thanks in advance.

1

There are 1 answers

2
Nitin Dhomse On BEST ANSWER

One of the following should work for you,

     def show(){
                 def taskName = Task.get(params.id)
                //Using redirect
                 redirect(controller: "AnotherController", action: "ActionInAnotherController", params: [taskName:taskName])

                //OR using forward

                def model = [
                    taskName : taskNme, 
                ]

                forward(controller:"AnotherController",action:"ActionInAnotherController", model:model)

                //OR using chain
                chain(controller:'AnotherController',action:'ActionInAnotherController ',model:model)

             //Redirect to another domain controller
               redirect(url: "anotherDomainUrl/AnotherController/ActionInAnotherController", params: [taskName:taskName])

 }