victor_33 Posted December 9, 2020 Share Posted December 9, 2020 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 More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 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? Link to comment Share on other sites More sharing options...
victor_33 Posted December 9, 2020 Author Share Posted December 9, 2020 Can you explain to me how to do that? Link to comment Share on other sites More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 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 Link to comment Share on other sites More sharing options...
victor_33 Posted December 9, 2020 Author Share Posted December 9, 2020 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 More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 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.htmlYou create a list with your beans and them create a datasource as the above. Link to comment Share on other sites More sharing options...
victor_33 Posted December 9, 2020 Author Share Posted December 9, 2020 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now