I would like to add a single parameter to my params
map, and bind the rest in a link. At the moment, I only bind the params
classically as follows:
<g:link class="email" controller="administrator" action="test" params="${params}">Link text</g:link>
How could I add a parameter to the params
map ?
Thank you in advance for you help. Regards,
EDIT:
Ok, I have find a way to do it.
params="${params + ['forwardURI': request.forwardURI]}"
I do not know if there is any more Grails-like way to do it. If there is one, I would be obliged to learn it ;)
If you have to do this repeatedly, you could use the answer you've posted in a g:link
wrapper Tag Library, as Tag Libraries have access to params
and request
.
def forwardAwareLink = { attr, body ->
attr.params = params + ['forwardURI': request.forwardURI]
out << g.link(attr, body)
}
And in the gsp:
<g:forwardAwareLink class="email" controller="administrator" action="test">Link text</g:forwardAwareLink>
If you want to use the tag with your own custom parameter map from the gsp, you can also use the following in the Tag Library:
attr.params = attr.params + ['forwardURI': request.forwardURI]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With