How to handle subclasses in JasperReports?

Posted by gotch4 on Stack Overflow See other posts from Stack Overflow or by gotch4
Published on 2011-11-24T09:27:09Z Indexed on 2011/11/24 9:50 UTC
Read the original article Hit count: 311

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about jasper-reports

Related posts about javabeans