bessokefashvili Posted April 30, 2019 Share Posted April 30, 2019 Greetings,I have Parameter $P{Names} with class: java.util.Collection and It has 2 values: "Name1" and "Name2"I've created Textfield with an expression: "Username: " + $P{Names}What I want to receive in report is:Username: Name1Username: Name2What I received is report is:Username: [Name1,Name2]Please help how can I fix this problem? How to separate values passed from collection Parameter? Link to comment Share on other sites More sharing options...
joseng62 Posted April 30, 2019 Share Posted April 30, 2019 The response you are getting is correct. Best would be to rather use a ArrayList and then .get(YouIndexNumber) to get the value. Then just increment your YouIndexNumber. Collection are not guaranteed to have fixed indices... Link to comment Share on other sites More sharing options...
bessokefashvili Posted May 2, 2019 Author Share Posted May 2, 2019 @joseng62Thank you for the reply, it worked but partially.When I've indicated IndexNumber - it returned only one specific valuefor example when I've entered: $P{Names} .get(0) it returned only the first value.What I need is a dynamic solution - that will return all the values separately so that I didn't have to write each IndexNumber separately and create multiple textfields. Link to comment Share on other sites More sharing options...
C-Box Posted May 3, 2019 Share Posted May 3, 2019 perhaps just an idea.... use simple java objects instead String Collection:something like:public class User{String userName;public User(String name){this.userName = name;}public String getUserName(){return this.userName;}}and when you create your Collection<User> somewhere in your java code and pass this as paramater "userList" to the fill process then you easily could create aJRBeanCollectionDataSource for a SubReport or jus a ListElement DataSourceExpression right in the jrxml-design new JRBeanCollectionDataSource($P{userList})Perhaps you could also create adHoc another DataSource from just an ArrayList<String> or whatever your parameter is typed of. Just take a look at the provided DataSource Implementations: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRDataSource.html hth + regardsC-Box Link to comment Share on other sites More sharing options...
bessokefashvili Posted May 7, 2019 Author Share Posted May 7, 2019 hi therewhat if I want to pass this array of objects via Rest.Is there any posible way for rest parameters to take array of objectsThanks a lot 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