如何在JasperReports中处理子类?

发布于 2024-12-17 13:58:22 字数 321 浏览 2 评论 0原文

我有两个扩展基类 BASE 的类(A 和 B)。我需要制作一份报告,该报告采用此类类的数组并打印 A 或 B 的字段。我尝试使用条件表达式,然后转换为一个或另一个(取决于字段值)。但我无法投射,因为我不知道如何引用当前的bean。

为此,我使用填充有 ListJRBeanCollectionDataSource。如何将报表(或子报表)中的每个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

汹涌人海 2024-12-24 13:58:22

使用 ((A) BASE) 假设 BASE 是您的 BASE 类

,现在 BASE 指向当前记录

use ((A) BASE) suppose BASE is your BASE class

now BASE point to the current record

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文