Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grails g:link pass params

I have something like this:

<g:each in="${temp}">

  <li>Date: ${it.dateParticipated}, <br>Role: ${it.role}, <br>Acceptence: ${it.accepted}, <br>
  <g:link controller="conference" action="participated" id="${it.conference.id}">
     Conference: </g:link>${it.conference},<br>
Role: ${it.role}, <br>Status: ${it.status}</li><br>

  <br>
</g:each>

What i want to do is, when i click on 'Conference', the controller 'conference' with the method 'participated' is loaded, and the params 'it.conference' is passed. How can i pass this params in the g:link tag ?

I need this because, when i click in the 'conference' word, other page is loaded with the conference details with the id passed.

like image 502
robert Avatar asked May 21 '11 23:05

robert


3 Answers

Use the params attribute to pass in a map of parameters:

<g:link action="/conference/participated" id="${it.conference.id}" params="[foo: 'bar', bar: 'foo']">My Link!</g:link>

See the documentation for more examples.

like image 157
Kaleb Brasee Avatar answered Nov 13 '22 03:11

Kaleb Brasee


You need to wrap your entire params with ${ }, instead of wrapping every variable that you want to pass separately.

<g:each in="${temp}">

  <li>Date: ${it.dateParticipated}, <br>Role: ${it.role}, <br>Acceptence: ${it.accepted}, <br>
  <g:link controller="conference" action="participated" params="${[id: it.conference.id, role: it.role, status: it.status]}">
     Conference: </g:link>

  <br>
</g:each>
like image 43
Arye Rosenstein Avatar answered Nov 13 '22 04:11

Arye Rosenstein


params="[customerId: customer.id]"
like image 3
Aaditya Bhatta Avatar answered Nov 13 '22 02:11

Aaditya Bhatta