Displaying an ArrayList parameter with a certain format in JasperSoft Studio report

I'm new to Jaspersoft Studio, so I'd like to know if it's possible to do the following:

The problem

For my report in Jaspersoft Studio, I'm passing in parameters from a java class, and one of the parameters is an ArrayList that contains information such as this:

ArrayList<String> benefits = new ArrayList<String>();

In my report, I need to display the information like this:

- Benefit: benefit_1
- Benefit: benefit_2
- Benefit: benefit_3
- Benefit: benefit_4

This ArrayList has a variable amount of items, so sometimes there are 4, sometimes only 2, etc.

How can I iterate through this list in the report and output it in this format?

What I've tried

From reading other similar questions here and on stackoverflow, I've tried adding a subreport with the ArrayList as the data source:

  <reportElement ... />
  <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{benefits})]]></dataSourceExpression>

But in the subreport, how would I display the ArrayList elements?

Or is it possible to do what I'm trying to do without the subreport?

chrisrollins65's picture
Joined: Jul 15 2015 - 3:39am
Last seen: 7 years 8 months ago

Well if anyone runs into a similar situation, I've posted a solution at http://stackoverflow.com/a/31447848/1193304

chrisrollins65 - 7 years 8 months ago

0 Answers:

No answers yet