简体   繁体   中英

Grails g:each tag

In grails I am trying to get every instance of a domain called Child to be printed out for that authorized user.

I am using the following:

 <g:each var="child" in="${Child}">
    <p>Name: ${child.firstname}</p>
    <p>Surname: ${child.lastname}</p>
 </g:each>

Each user can have several children (Child) and I want it to list the children for the currently logged in user. I am using spring source security core plugin for my login etc.

This is my exception:

Class : groovy.lang.MissingPropertyException Message : No such property: firstname for class: com.fyp.timeline.Child Possible solutions: firstname, lastname

Any ideas?

<g:each var="child" in="${user.children}">
   <p>Name: ${child.firstname}</p>
   <p>Surname: ${child.lastname}</p>
</g:each>

user is an instance of logged in user where

User{
    static hasMany=[children:Child]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM