Search code examples
model-view-controllergrailsgroovy

i can't display my data from different domains in grails


i want to display data from multiple domain in grails. when i send my data to view it only executes or display the first "each" i am sending data like this

def list(){
    [user :User.list(), address: Address.list(), contact: Contact.list()]
}

my code for View is here

    <g:each in="${user}">

    First Name: ${it.firstName}
    Last Name: ${it.lastName}
    Email: ${it.email}

    </g:each>

    <g:each in="${address}">

    Permanent Address : ${it.perAddress}
    Present Address : ${it.preAddress}
    </g:each>

    <g:each in="${contact}">

    Mobile Number : ${it.phoneNumber}
    LandLine Number: ${it.landNumber}

    </g:each>

and the View Side is


Solution

  • Try instead (for example):

    <g:each var="a_user" in="${user}">
        First name: ${a_user.firstName}
    </g:each>
    

    though I would rename your "user" to "users", "address" to "addresses", etc to make it more clear and idiomatic...

    <g:each var="user" in="${users}">
        First name: ${user.firstName}
    </g:each>