Sumon Bappi
Sumon Bappi

Reputation: 2019

grails g:each tag is not showing anything in view

I am using grails 2.4.2. I need to show some value in view from a list. That's why I am using g:each but nothing is shown to view although it's working fine in controller. I never saw this issue before. Can anybody please help me on this please ?!!! Here are my attempts below :::

in my controller ##

def homePage() {
    def androidGameInstance = AndroidGameDist.listOrderByDownloadCount(order: 'desc',max: 10)
    androidGameInstance.each {
        println(it.downloadCount)
    }
    [androidGameInstance: androidGameInstance]
}

in my view ##

<body>
<g:each in="${androidGameInstance}" status="i" var="androidGameInstance">
    <p>value : ${androidGameInstance.downloadCount}</p>
</g:each>

Upvotes: 0

Views: 199

Answers (1)

David Chavez
David Chavez

Reputation: 617

Try with this:

Controller:

def homePage() {
    def androidGameInstanceList = AndroidGameDist.listOrderByDownloadCount(order: 'desc',max: 10)
    androidGameInstanceList.each {
        println(it.downloadCount)
    }
    [androidGameInstanceList: androidGameInstanceList]
}

gsp:

<g:each in="${androidGameInstanceList}" status="i" var="androidGameInstance">
    <p>value : ${androidGameInstance.downloadCount}</p>
</g:each>

Upvotes: 1

Related Questions