azielke Posted May 29, 2010 Share Posted May 29, 2010 Hi all,I'm using JasperReports 3.7.2. I'm creating a report, using the Java compiler. Now I'd like to add an IN clause using the $X{} Syntax.My query isselect FIRST_NAME, SURNAME from test_data where $X{IN, FIRST_NAME, FIRST_NAMES}Regarding the parameter, the JasperReports Ultimate Guide states, that "The name of the report parameter that will supply the values list. The value of this parameter can either be a java.util.Collection instance or an object or primitive Java array."I'd like to declare my parameter FIRST_NAMES as array of java.lang.Strings. I want to do this to keep the type information of the elements, which I'd loose if I used a Collection. Therefore I tried using [Ljava.lang.String; as type, which is the way you'd obtain a String[] using reflection. This results in net.sf.jasperreports.engine.design.JRValidationException: Report design not valid : 1. java.lang.ClassNotFoundException: [L;When I use "java.lang.String[]", the report compiles (in iReport), but I fail to supply values for the parameter. I tried "Mack" {"Mack"} String[] {"Mack"} new java.lang.String[]{"Mack"}All these attempts ended with anjava.lang.NoSuchMethodException: [Ljava.lang.String;.<init>(java.lang.String) at java.lang.Class.getConstructor0(Class.java:2706) So, could anyone supply me with the correct way to do this? Thanks. Link to comment Share on other sites More sharing options...
thangalin Posted May 31, 2010 Share Posted May 31, 2010 java.util.List Link to comment Share on other sites More sharing options...
azielke Posted May 31, 2010 Author Share Posted May 31, 2010 Thanks for the answer, but that doesn't work. When I supply java.util.Arrays.asList(new String[]{"August", "Barbara"})as parameter, no restriction regarding the first name is applied. Also the NoSuchMethod Exception is still thrown. Link to comment Share on other sites More sharing options...
thangalin Posted May 31, 2010 Share Posted May 31, 2010 new java.util.ArrayList( java.util.Arrays.asList( new String[] { "August", "Barbara" } )) That's what I did (except using Integer types) to pass in an array to be used as:$X{ IN, C.ID, CityCode } Post Edited by thangalin at 05/31/2010 15:02 Link to comment Share on other sites More sharing options...
azielke Posted May 31, 2010 Author Share Posted May 31, 2010 And your parameter is declared as String-array, or is it a List or some other Collection? I'm asking because I'm declaring my parameter FIRST_NAMES as array of java.lang.Strings. I do this to keep the type information of the elements, which I'd loose if I used a Collection. I'm using the type information in my client application to generate "typed" UI widgets. Link to comment Share on other sites More sharing options...
thangalin Posted May 31, 2010 Share Posted May 31, 2010 The CityCode parameter was declared as java.util.List. The Default Value Expression was what I showed above. I may have had to do some type conversions because the data came in from a comma-delimited list in an HTML form, passed through PHP, then bridged into JasperReports. Link to comment Share on other sites More sharing options...
thangalin Posted September 27, 2010 Share Posted September 27, 2010 If using Groovy as the report's language, it's even easier: ["August", "Barbara"] 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