Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a string for a link in grails without g:link

Tags:

grails

gsp

In a tag like below:

<a data-url="/new/request/showText/${requestInstance.id}"> view text</a>

Is there a way to not hardcode the url like I have?

I tried using <g:link action="showText" id="${requestInstance.id}"> but that renders to an anchor tag.

What I'm doing might be find but I'm just curious if there is a better way to do this in grails?

like image 549
birdy Avatar asked Dec 27 '22 11:12

birdy


1 Answers

You may use

${createLink(action:'myaction',params:[datasetId:dataset.id])}

for full control. It just returns something like http://myapp/myaction/123 and supportsall the params which g:link supports.

To be more specific:

<a data-url="${createLink(action:'showText',id: requestInstance.id)}"> view text</a>

should work.

like image 96
Martin L. Avatar answered Feb 12 '23 13:02

Martin L.