Jump to content
Changes to the Jaspersoft community edition download ×

How to provide input to $X in iReport?


wpfeiffe

Recommended Posts

I have a very simple report that uses the $X{} syntax to build the IN clause. I have test code written in groovy that runs the report just fine by passing in a collection of Strings.

 

My question is, how do I provide the same input when previewing the report within iReport? I have the parameter of type java.util.Collection and get prompted for it when I attempt to preview, at which point I get a single line edit control.

 

Doing research on this forum, I have seen the following syntax suggested:

Code:
java.util.Arrays.asList(new String[]{"String1", "String2"})

I tried this with the same dataset as I use in my test code (which produces rows just fine), but all I got was an empty report.

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

The syntax below is good as a default value, for example, inside the .jrxml.

 

If you want to enter a value interactively in iReport it's easier. iReport is smart enough to convert your values into a collection, so you can just enter something like this when you are prompted for a value:

String1,String2

 

Regards,

Matt

JasperSoft

Link to comment
Share on other sites

Matt,

 

Thanks for you response. I tried just putting in the comma delimited strings and it certainly works and this is good.

 

However, I immediately must ask how iReport handles String values with commas? I really expected to see the individual strings delimited by at least some type of quotes.

 

Perhaps the proper question is: can you point me to the docs that specify how this works. I have the paid documentation, but didn't see anything concerning how this (Entering collection parameters in iReport gui) works.

 

Given that it works at all, I would leave good enough alone, but I am trying to sell this to my dba/report writers group who will ask me the same questions I'm posting here.

 

Thanks for any additional help and especially for your first answer which got this working for me!

 

Bill

Link to comment
Share on other sites

Bill,

 

I haven't tried entering quoted strings into the iReport prompt. From your post I infer that it doesn't like the quotes.

 

If that's the case then it could be a valid enhancement request to add that ability. Then you could enter data like this:

"String1,isn't quite done,now it is.","String2"

 

It would be valid, but I expect that it's relatively low priority. That's because normally iReport is only used for testing the report a bit. When the report is actually deployed to production you won't use iReport at all. And in production the input control accepting the strings will happily accept strings with commas. Additionally, you can set the param to allow commas in the strings from within iReport by setting a default value for the param using the initially suggested syntax.

 

But that's just one opinion. ;-) Please enter a log for it if you think it would make your iReport experience better.

 

Regards,

Matt

Link to comment
Share on other sites

  • 2 weeks later...

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