Convert string to collection


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.

victor_33's picture
Joined: Jul 22 2020 - 6:21am
Last seen: 1 month 2 weeks ago

Why don't you split your strings, put the data in some simple bean list, use the list to create a JRBeanCollectionDataSource, and pass it as the datasource or your report, instead of passing string parameters?

gustavofarias - 2 months 3 weeks ago

Can you explain to me how to do that?

victor_33 - 2 months 3 weeks ago

how do you pass 2 parameters to your report? in some moment in your code you call jasperreports and passes the parameters and the connection or the datasource. You didn't provide any info about how you run your report

gustavofarias - 2 months 3 weeks ago
show 3 more...

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.

victor_33 - 2 months 3 weeks ago

have a look at this method:,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:

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

gustavofarias - 2 months 3 weeks ago

Can i use this method when i call the report from jasperserver?
Since the data is not static, the data is filled by the user, so i dont know if it works. Btw im not programming in java, and i dont know much about java, its a angular project.

victor_33 - 2 months 3 weeks ago

0 Answers:

No answers yet