Object.getText() ireport 中的表达式



在iReport设计器中,我创建了一个名为address的字段,该字段的类型为java.lang.Object,我创建了一个表达式为$F{address}.textTextaddress的数据是一个java.util.Map,看起来像这样:

["bldgname":null, "barangay":["name":"MINAULON", "objid":"057-01-0013"], "province":"LANAO DEL NORTE", "text":"MINAULON, BACOLOD, nLANAO DEL NORTE", "unitno":null, "type":"local", "bldgno":null, "pin":null, "city":null, "subdivision":null, "municipality":"BACOLOD", "street":null]

预览报表后,抛出错误,指出:

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : $F{address}.text
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:197)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:537)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:505)
    at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:826)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:368)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:353)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:426)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:311)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:247)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:879)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:801)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
    at com.rameses.osiris2.reports.ReportModel$JReportInfo.fillReport(ReportModel.java:329)
    at com.rameses.osiris2.reports.ReportModel.createReport(ReportModel.java:163)
    at com.rameses.osiris2.reports.ReportModel.viewReport(ReportModel.java:169)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:195)
    at WaterworksAccountBill.viewReport(com.rameses.gov.etracs.waterworks.models.WaterworksAccountBill:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:665)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
    at WaterworksAccountBill.invokeMethod(com.rameses.gov.etracs.waterworks.models.WaterworksAccountBill)
    at com.rameses.custom.impl.MethodResolverImpl.invoke(MethodResolverImpl.java:27)
    at com.rameses.rcp.util.ControlSupport.invoke(ControlSupport.java:123)
    at com.rameses.osiris2.client.WorkUnitUIController.init(WorkUnitUIController.java:163)
    at com.rameses.rcp.util.ControlSupport.initOpener(ControlSupport.java:221)
    at com.rameses.rcp.util.ControlSupport.initOpener(ControlSupport.java:182)
    at com.rameses.rcp.impl.NavigationHandlerImpl.navigate(NavigationHandlerImpl.java:39)
    at com.rameses.rcp.util.UICommandUtil.processAction(UICommandUtil.java:115)
    at com.rameses.rcp.control.XButton.actionPerformed(XButton.java:284)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
    at java.awt.Component.processMouseEvent(Component.java:6288)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6053)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4651)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:602)
    at java.awt.EventQueue$1.run(EventQueue.java:600)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
    at java.awt.EventQueue$2.run(EventQueue.java:616)
    at java.awt.EventQueue$2.run(EventQueue.java:614)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: groovy.lang.MissingPropertyException: No such property: text for class: com.rameses.osiris2.reports.ReportDataSource

如何解决这个问题?我用Groovy作为语言。

错误显示

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : $F{address}.text
...
Caused by: groovy.lang.MissingPropertyException: No such property: text for class: com.rameses.osiris2.reports.ReportDataSource

似乎$F{address} 不是一个 java.util.Map 实例,而是一个 com.rameses.osiris2.reports.ReportDataSource 对象。

仔细检查数据源中字段的类型。

最新更新