view t...">

Creating a line for a link in grails without g: link

In the tag as shown below:

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

Is there a way to not hardcode the url like mine?

I tried using <g:link action="showText" id="${requestInstance.id}"> but this displays the anchor tag.

What can I do, but I'm just wondering if there is a better way to do this in the grail?

+4
source share
2 answers

you can use

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

for complete control. It just returns something like http://myapp/myaction/123 and supports all the parameters supported by g:link .

More specific:

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

must work.

+9
source

You can use the createLink function inside ${..} .

So in your case it will be:

 <a data-url="${createLink(controller: 'yourController', action: 'yourAction', params:[param1: 'value1'])}"> view text</a> 
+1
source

All Articles