Search code examples
grailsgroovygsp

Passing parameters in Links - Grails


In the following code sample I am passing ID as a parameter. However, I want to pass userID as well as a parameter. So overall I will be passing 2 parameters. How can O do this ?

<td>
   <g:link
      url="${fieldValue(bean: gInstance, field: "name")}"
      id="${gInstance.id}" >
      ${fieldValue(bean: gInstance, field: "name")}
   </g:link>
</td>

How can I pass gInstance.userID as a 2nd parameter in the example above?


Solution

  • You can send extra params like this

    <g:link url="${fieldValue(bean: gInstance, field: "name")}" id="${gInstance.id}" params="['userId': gInstance.userID]">
        ${fieldValue(bean: gInstance, field: "name")}
    </g:link>