Reputation: 4257
I'm using the Grails Jasper report plugin in my application. Im trying to bind a collection of Expandos to my report template.
My Expando is built as follows
def calendarTask = new Expando()
calendarTask.title = task.name
calendarTask.date = new Date()
data.add(calendarTask)
I then bind the collection in my controller
chain(controller:'jasper', action:'index', model:[data:data], params:params)
In my report I have a field called "title" (type string) defined in my report template. When I try and run this report I get the exception below. Can you bind Groovy Expando collection to jasper reports?
java.lang.NoSuchMethodException: Unknown property 'title' on class 'class groovy.util.Expando'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1313)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
Upvotes: 2
Views: 470
Reputation: 171084
I wrote a quick test script, and it gave the same error
@Grapes(
@Grab(group='commons-beanutils', module='commons-beanutils', version='1.8.3')
)
import org.apache.commons.beanutils.PropertyUtilsBean
def calendarTask = new Expando()
calendarTask.title = { -> 'tim' }
calendarTask.date = { -> new Date() }
println new PropertyUtilsBean().getProperty( calendarTask, 'title' )
So it looks like common-beanutils
and Expando
don't play well together...
However, if you change from using Expando
to just using a plain Map
, the beanutils call works, so could you try changing your code to:
def calendarTask = [
title : task.name,
date : new Date(),
]
data.add(calendarTask)
Upvotes: 2