Thursday, November 24, 2011

grails dynamic variable in createLink tag

The problem

I was trying to output the value of a variable inside the params attribute of the createLink grails tag, as follows:

<g:createLink action="listSnpsByIglId" params="[iglId:${sampleInstance.iglId}]" />

But that didn't work, with grails failing to evaluate the expression.

The solution

Instead the ${} should be wrapped around the whole expression as follows:

<g:createLink action="listSnpsByIglId" params="${[iglId:sampleInstance.iglId]}" />


References:

No comments:

Post a Comment