This page last changed on Mar 09, 2006 by graeme.rocher@gmail.com.
Tag - link
Description
Creates a html anchor tag with the href set to based on the parameters specified
Parameters
- action (optional) - the name of the action to use in the link, if not specified the default action will be linked
- controller (optional) - the name of the controller to use in the link, if not specified the current controller will be linked
- id (optional) - The id to use in the link
- url (optional) - A map containing the action,controller,id etc.
Examples
Example controller for an application called "shop":
class BookController {
@Property defaultAction="list"
@Property list = { [ books: Book.list( params ) ] }
@Property show = { [ book : Book.get( params['id'] ) ] }
}
Example usages for above controller:
<g:link action="show" id="1">Book 1</g:link> == <a href="/shop/book/show/1">Book 1</a>
<g:link controller="book">Book Home</g:link> == <a href="/shop/book">Book Home</a>
<g:link controller="book" action="list">Book List</g:link> == <a href="/shop/book/list">Book List</a>
<g:link url="[action:'list',controller:'book']">Book List</g:link> == <a href="/shop/book/list">Book List</a>
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>
|