Test User
Test User

Reputation: 57

How to pass values from view to controller in grails

I need to pass the Id value to my controller to execute the action. Currently this is what I have in my controller.

    def StartServer() {
    amazonWebService.ec2.startInstances(new StartInstancesRequest([InstanceToStart]))
    redirect action: index()
    }

The InstanceToStart value will come from the view. In my view I have a table with the following columns, Id and button:

i-333dced <Button>
i-dhdhdhd <Button>
i-er32ws  <Button>

When I press the button I want the Id to pass and then execute my action. My button code is as follows:

  <g:link action="StartServer">
  <input type="button" value="Start Server" class="stopimg" id="startServer"/>
  </g:link>

Upvotes: 0

Views: 2269

Answers (1)

dmahapatro
dmahapatro

Reputation: 50275

Use anyone from above according to your need. I bet you will also get samples/questions/answers here in SO related to the same requirement if you search.

Upvotes: 4

Related Questions