Jump to content

Working with - java.util.Collection Parameter


bessokefashvili

Recommended Posts

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: Name1

Username: Name2

What 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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

 

@joseng62

Thank you for the reply, it worked but partially.

When I've indicated  IndexNumber - it returned only one specific value

for 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

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 a

JRBeanCollectionDataSource 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 + regards

C-Box

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