Jump to content

Multi-Select Problem


tim.newell

Recommended Posts

I am new to Jaspersoft/Java and have run into an issue in getting Jaspersoft's multi-select feature to work properly.

Javascript is being used to collect the values that are fed to the report.

The multi-select parameter is defined as a collection with a nested type of string.  Another string parameter is defined and used in the default expression.

The default expression is as follows:

<defaultValueExpression><!CDATA[java.util.Arrays.asList(new String[]{$P{PARAM1})]]></defaultValueExpression>

The  javascript code would put the selected values into PARAM1 that would then be passed to the report.

When a single selection is made the report works properly.  Unfortunately when multi-selections are made the report always returns null.

When PARAM1 is replaced with a list of hardcoded values such as ('25','22') the report works properly.

The report also runs properly in JasperStudio  when multiple selections are made.  I just can't get it to work when the selections are made using javascript. 

Does anyone have any thoughts as to what might be going on?

Thanks.

 

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

I tried that but I kept getting a message  to the effect that the parameter INPUT_CONTROL_NAME was a string even though it was defined as a List.  That is why I tried using the default value expression.  

It could be because I didn't know what  INPUT_CONTROL_ NAME parameter was expecting to receive.  I tried lots of formats but I could never get it to work.  Passing a single value would work, but the report would return nothing whenever I tried to pass multiple values.  

Ultimately I simply modified the javascript code to pass both the query expression and the data to the report parameter.   Something along the lines of  "column_name IN (value1, value2,...)" would be passed to the report via the parameter.  This approach works fine although I would have preferred to use $X  and certainly would like to know why it is not working.

Link to comment
Share on other sites

Which version of jasperserver are you using ?

My jasperverer: 7.1.0

And works fine.

1.- Input Control as multiselect.

2.- Parameter in Report Unit as java.util.List with exactly same ID as Input Control. Delete Default Value from parameter.

3.- Use $X{IN, FIELD_NAME, INPUT_CONTROL_NAME}  in where section of sql query.

That's all.

Regards,

Mariano

Link to comment
Share on other sites

I did try the $X  but I received the message that the parameter was defined as a string even though it was defined as a list.  That is when I tried using the default expression which worked when I passed a single value but returned null when I passed multi-values.

We are not using JasperServer.  We are Java and Javascript and the Jasper Reports library.

the report works when I test it using Jaspersoft Studio (Community ver 5.6.00) meaning I am prompted to enter the multi-select values and the program executes properly so my syntax was correct. 

It likely has something to do with what the java.util.list parameter is expecting as input from the javascript code.  I tried a variety of different formats with no success.

When I get a chance I will try it again as maybe something wasn't defined correctly.  As I stated I did find a work around so I am not stuck.

Thanks for your assistance.

 

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