"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Tags/include.html" (14 Sep 2022, 62386 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)

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 a controller, tag library or GSP:

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

Description

Attributes

  • action (optional) - the name of the action to use in the include

  • controller (optional) - the name of the controller to use in the include

  • id (optional) - the id to use in the include

  • view (optional) - The name of the view to use in the include

  • params (optional) - a Map of request parameters

  • model (optional) - Any request attributes (the model) to pass to the view to be included