views:

100

answers:

1

Assume I have the following classes

class Genre {
    static hasMany=[author:Author]
}

class Author{

    static hasMany=[books:Books]
}


class Books{
       Author author 
}

How do I go about printing this in the gsp using g:each tag?

+2  A: 

If you want to display all books by author you could have something like

<g:each var="author" in="${Author.list()}">
    <p>Author: ${author.fullName}</p>
    <ul>
    <g:each var="book" in="${author.books}">
        <li>${book.title}</li>
    </g:each>
    </ul>
</g:each>

Cheers!

lunohodov
will try. thanks!
Neoryder
You missed Genre.
Scott Warren
@Scott: You are right! I did it for clarity as the question is about nesting g:each tags :)Cheers
lunohodov