在子报表编译期间,iReport中出现错误:
Errors compiling E:\workspace_new\kidslake\src\main\resources\admissionForm_sub_1.jasper!
Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@28f84e61
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method getFullName() is undefined for the type Object
value = ((java.lang.Object)field_director.getValue()).getFullName(); //$JR_EXPR_ID=17$
2. The method getFullName() is undefined for the type Object
value = ((java.lang.Object)field_director.getOldValue()).getFullName(); //$JR_EXPR_ID=17$
3. The method getFullName() is undefined for the type Object
value = ((java.lang.Object)field_director.getValue()).getFullName(); //$JR_EXPR_ID=17$
3 errors
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:204)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:512)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
我的豆类就像
class Mainclass{
private List<AdmissionForm> admissionForm;
//getter
//setter
}
class AdmissionForm{
private Director director;
//getter
//setter
}
class Director{
private String fullName;
//getter
//setter
}
我在主报告中将
JRBeanCollectionDataSource
作为MainClass
列表传递我定义了子报告和传递字段
new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{admissionFormList})
我定义了在子报表中访问Director的全名属性
$F{director}.getFullName()
但是当我编译主报告或子报告时出现上述错误。
帮我解决我的问题
最佳答案
您可以执行以下操作之一:
将director
报告字段的类型设置为Director
(完整/合格的类名称)。显然,当前字段类型为java.lang.Object
将报告语言更改为Groovy。
声明一个名为director.fullName
的报告字段,并直接使用该字段代替$F{director}.getFullName()