I have something like this
<g:each in="${category}" status="i" var="cat">
<li class="demo_li"><g:link action="listGame"><img id= "icon" src="${resource(dir: 'icons', file: "${cat.icon}")}"><div>${cat.categoryName}</div></g:link></li>
I want to pass the value of ${cat.categoryName} to the controller if i click on it how do I do this?
The Grails g:link tag has a params
attribute you can use to pass parameters to a controller action. The params
is a Map
. Lets say you name the parameter categoryName. You'd specify it like this:
<g:link action="listGame" params="${[categoryName: cat.categoryName]}">..</g:link>
In your controller's listGame()
action you can access the parameter like this: params.categoryName