2010-03-18 9 views
5

Si supponga Ho le seguenti classiCome annidi g: ogni tag in gsp?

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

class Author{ 

    static hasMany=[books:Books] 
} 


class Books{ 
     Author author 
} 

Come posso fare per la stampa di questo nel SPG con g: ogni tag?

risposta

9

Se si desidera visualizzare tutti i libri per autore si potrebbe avere qualcosa di simile

<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!

+0

proverà. Grazie! – Neoryder

+0

Ti sei perso Genere. –

+2

@Scott: hai ragione! L'ho fatto per chiarezza dato che la domanda riguarda nidificazione g: ogni tag :) Cheers – lunohodov

Problemi correlati