John Little
John Little

Reputation: 12439

how to get grails f:table working (3.3.8)

grails is great, but where there is no example its very hard to use.

In my view I have:

<f:table collection="${bankAccountList}"/>

in my controller I tried as many variations as I could think of, e.g:

:
respond BankAccount.findAllByUser(user)
}

and

:
def bankAccounts = BankAccount.findAllByUser(user)
[bankAccountList: bankAccounts]
}   

I also tried what is in the oficial documentation for the view:

 <f:table collection="bankAccountList"/>

The error I always get is:

Class
java.lang.NullPointerException
Message
Request processing failed; nested exception is org.grails.gsp.GroovyPagesException: Error processing GroovyPageView: [views/dashboard/index.gsp:10] Error executing tag <f:table>: [views/templates/_fields/_table.gsp:5] Error executing tag <g:sortableColumn>: null

BankAccount.findAllByUser(user) is definitely returning the players bankAccount records.

Any ideas?

Upvotes: 0

Views: 228

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27255

You have not provided enough information to say for sure what is wrong but if you pass a List of BankAccount instances to the respond method, then in the view you will be able to use <f:table collection="${bankAccountList}" />.

The project at https://github.com/jeffbrown/johnlittletable demonstrates that.

See the use of the f:table tag at https://github.com/jeffbrown/johnlittletable/blob/99e6c5c36e6a1b72ab6f20552fd66e0a67767927/grails-app/views/bankAccount/index.gsp#L21.

I hope that helps.

Upvotes: 1

Related Questions