I'm passing a List as a JRBeanCollectionDataSource to a Subreport. Here Object is of Type A
and B
. The object type A
has two properties: name
and address
and the object type B
has the location
property.
If Object is of type A
then I have to display name
and address
in subreport. And if it is of type B
then I have to display location
in subreport.
I have to access a type of Object in a subreport, means is of which type (A
or B
)?.
I have tried a lot but not found any solution.
Can anyone help me please. Thanks in advance.
You have many options:
First: Put a flag field in both objects stating is this Object A or Object B.
Then in
Subreport Expression
use a ternary statement like this:Second: Pass the sub report name as a field inside the object itself.
Then in
Subreport Expression
use the field like:Third: Make two subreports each is populated by its own type. If you want to show "Subreport A" then populate ObjectA and leave ObjectB list as null. In Jasper, if the populating list is
NULL
, the subreport is not rendered.