i have a Media Domain
def Media {
String name
static belongsTo = [parent:Media]
static hasMany = [children:Media]
}
In the show.gsp page i want to list all my root Media (that haven't parent) into an ul list an their children and their children recursively in another ul lists. I have used the Tag for the first list but i don't know how to do this recursively for the children.
So have you an idea of how to do this ?
Thanks.
You could put the recursive part into a GSP-template and then call it recursively, e.g.:
index.gsp: Assuming rootMedias is passed into the view
<g:each in="${rootMedias}" var="media">
<g:render template="step" model="${[media: media]}" />
</g:each>
_step.gsp
<ul>
<g:each in="${media.children}" var="child">
<li>
${child.name}
<g:render template="step" model="${[media: child]}" />
</li>
</g:each>
</ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With