Reputation: 10623
I'm trying to create a link with a dynamic link like:
<g:link action="${nextDashboardUriMap.nextAction}" params="${["$nextDashboardUriMap.queryStringId": "$entityId" ]}">
${entityName}
</g:link>
where nextDashboardUriMap.queryStringId
contains xyz
and entityId
contains 12
.
I was expecting url of the link to be http://website.com/controller/action?xyz=18
but <g:link/>
consistently gives me http://website.com/controller/action?xyz
.
I have tried replacing entityId
with a string literal.
Upvotes: 1
Views: 231
Reputation: 122414
You don't need to use GStrings here, you can simply say
<g:link action="${nextDashboardUriMap.nextAction}"
params="[(nextDashboardUriMap.queryStringId):entityId]">
Upvotes: 2
Reputation: 2789
It seems that it may be this bug: GRAILS-9774 - the value is lost if key in params map is of type GString
. Converting the key to String
should resolve your problem:
<g:link action="${nextDashboardUriMap.nextAction}"
params="${[("$nextDashboardUriMap.queryStringId".toString()): "$entityId" ]}">
(...)
Upvotes: 1
Reputation: 911
how about
<%
Map paramsMap = [:]
paramsMap[nextDashboardUriMap.queryStringId] = entityId
%>
<g:link action="${nextDashboardUriMap.nextAction}" params="${paramsMap}" >${entityName}
</g:link>
Upvotes: 0