include

Purpose

Includes the response of another controller/action or view in the current response

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:include action="show" id="1" />
<g:include action="show" id="${currentBook.id}" />
<g:include controller="book" />
<g:include controller="book" action="list" />
<g:include action="list" params="[sort:'title',order:'asc',author:currentBook.author]" />

Example as a method call in controllers, tag libraries or GSP:

def content = g.include(action:'list',controller:'book')

Description

Attributes

Source

Show Source