Jump to content

Convert string to collection


victor_33

Recommended Posts

So, i have a report that has 2 parameters that are strings and look like this, "1,2,3" "john,dave,bob", and i want to iterate them into the detail band, how can i do that? I tried to cast them to collection using .split(",") but cant seem to iterate them. Any help would be appreciated.

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I call the report in my code when a button is pressed, and some parameters are sent, 2 of them are strings that i need to show in the detail band. I dont run any sql in this report. Its all about the data i get from the parameters to build the report.

Link to comment
Share on other sites

have a look at this method:

http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperRunManager.html#runReportToPdf(java.lang.String,java.util.Map,net.sf.jasperreports.engine.JRDataSource)

One of the parameters is a datasource. This is where you put your data. Not in the parameters.

One of the datasources you could use in your case is this:

http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/data/JRBeanCollectionDataSource.html

You create a list with your beans and them create a datasource as the above.

Link to comment
Share on other sites

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...