Two domain objects in one view

Can two domain objects appear on the same page when the list method is called, for example?

http: // APP_NAME / foo / list


def list = {
    if(!params.max) params.max = 10
    [ fooList: Foo.list( params ) ]
    [ barList: Bar.list( params ) ]  // Only the last one is returned.

}

On the watch page, both pages will be displayed on the page.

 <g: each in = "$ {fooList}" status = "i" var = "foo"> ... </ g: each>
 <g: each in = "$ {barList}" status = "i" var = "bar"> </ g: each>
+3
source share
2 answers

Pretty sure you can return a few things in this last line:

[fooList: Foo.list (params), barList: Bar.list (params)]

+7
source

The comma in the accepted answer is correct, you can delete the // line.

0
source

Source: https://habr.com/ru/post/1698325/


All Articles