如何在JasperReports中处理子类?
我有两个扩展基类 BASE 的类(A 和 B)。我需要制作一份报告,该报告采用此类类的数组并打印 A 或 B 的字段。我尝试使用条件表达式,然后转换为一个或另一个(取决于字段值)。但我无法投射,因为我不知道如何引用当前的bean。
为此,我使用填充有 List
的 JRBeanCollectionDataSource
。如何将报表(或子报表)中的每个 bean 转换为 A 或 B?我尝试过:
((A)this)
但它基本上说这包含报告实例,而不是当前的 bean 并给出错误。
I've two classes (A and B) that extend a base class BASE. I need to make a report that takes an array of such classes and the prints the fields of A or B. I tought of using conditional expressions, then casting to one or another (depending on a field value). But I can't cast, because I don't know how to refere to the current bean.
To do this I am using a JRBeanCollectionDataSource
filled with a List<BASE>
. How do I cast every bean to A or B in a report (or subreport)? I tried:
((A)this)
but it says basically that this contains the report instance, not the current bean and gives error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
((A) BASE)
假设BASE
是您的 BASE 类,现在
BASE
指向当前记录
use
((A) BASE)
supposeBASE
is your BASE classnow
BASE
point tothe current record