Illep
Illep

Reputation: 16851

Open view in a new tab - grails

I have a URL, and then the user clicks on the following i need this URL to be opened in a new Tab. How can i do this.

The URL i want to open is http://lhost/pro/app/showusers?p=0&u=90

My Grails code look as follows: How can i open the above link that will open in a new tab

<td><g:link action="showusers" id="${fieldValue(bean: userInstance, field: "name")}">${fieldValue(bean: userInstance, field: "name")}</g:link></td>

Update :

When i click on the above link i get http://lhost/pro/app/showusers/5 as the URL but i want to display http://lhost/pro/app/showusers?p=0&u=90 as the URL. How can i do this ?

Upvotes: 2

Views: 5949

Answers (1)

Joshua Moore
Joshua Moore

Reputation: 24776

Using the target attribute of the link element you can do this. You can give the tab/window a name or use _blank and allow the browser to assign a new name internally. Using the same name will target the same window/tab if it's already open.

Most (if not all) Grails standard tags will echo any additional attributes as HTML element attributes when present.

For example:

<td><g:link action="showusers" id="${fieldValue(bean: userInstance, field: "name")}" target="_blank">${fieldValue(bean: userInstance, field: "name")}</g:link></td>

You can read more about the link/href element here.

Upvotes: 11

Related Questions