Jump to content
Changes to the Jaspersoft community edition download ×

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


chrisrollins65

Recommended Posts

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>();benefits.add("benefit_1");benefits.add("benefit_2");benefits.add("benefit_3");benefits.add("benefit_4");

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:

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

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?

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...