link

Purpose

Creates an html anchor tag with the href set based on the parameters specified.

Examples

Example controller for an application called "shop":

class BookController {
     def list = { [ books: Book.list( params ) ] }
     def show = { [ book : Book.get( params['id'] ) ] }
}

Example usages for above controller:

<g:link action="show" id="1">Book 1</g:link>
<g:link action="show" id="${currentBook.id}">${currentBook.name}</g:link>
<g:link controller="book">Book Home</g:link>
<g:link controller="book" action="list">Book List</g:link>
<g:link url="[action:'list',controller:'book']">Book List</g:link>
<g:link action="list" params="[sort:'title',order:'asc',author:currentBook.author]">
     Book List
</g:link>
<g:link controller="book" absolute="true">Book Home</g:link>
<g:link controller="book" base="http://admin.mygreatsite.com">Book Home</g:link>

Example as a method call in GSP only:

<%= link(action:'list',controller:'book') { 'Book List' }%>

Results in:

<a href="/shop/book/list">Book List</a>

Description

Attributes

Source

Show Source