Reputation: 1
I need to get the results of a database search to print out on a gsp page. I currently have this
<h1>Invoices</h1>
<g:each in="${dueInvoices}" var="di">
<li>${di}</li>
</g:each>
All I get back when I load the page
Invoices invoicetest.Invoices
I have also tried naming each column in a database inside an HTML table and still just get the same thing back
My groovy code to make this work is
def dueInvoices(){
def today = new Date()
def invoices = Invoices.findAllByDueDateLessThan(today + 6)
render(view: "dueInvoices", model: [dueInvoices : Invoices ])
This code is used to find all invoices that are due in the next 6 days
Upvotes: 0
Views: 49
Reputation: 12228
In the model, you are passing down the class instead of your list of instances:
def invoices = Invoices.findAllByDueDateLessThan(today + 6)
render(view: "dueInvoices", model: [dueInvoices : invoices ])
Upvotes: 3