Multi-select input controls in JasperServer

Sooner or later, while developing a JasperServer–hosted reports, you will require parameteres and input controls which allow you to select more then one value. Usually there is a need for an input control, which allows either single value, single value with an option "ALL", or multiple values. Of course, the input controls are populated from database as I described in previous write-up.

Today I will describe how to create an input control which allows to select multiple values. First of all you need to define a parameter. In iReport's editor panel Document structure right–click on Parameters and select Add… > Parameter. Datatype java.util.Collection is most important setting.

In JasperServer we will define appropriate input control which allows us to select multiple values. Having a source Query in JasperServer defined, we will select Add > Input Control in iReport's JS–Plugin 3.0 panel, select Multi–Select Query type and fill in other values as for Single–Select Query. We will link the input control to the Report Unit.

Last and most important thing is to use the parameter in report. Because there might be various count of parameter values, we will use WHERE table.attr IN(…) clause to restrict the query. Ordinary single–value parameters are encoded using syntax $P{ParameterName}. For multi-value parameters there is a special syntax – $X{IN, table.attr, ParameterName} which generates the query condition. You can use NOTIN insted of IN in case you would like to generate the NOT IN(…) clause.

The multi-select input control will show as a selectbox with multiple lines displayed and you can select multiple values as well.

Comments:

Thank you! that tutorial was very useful!

Posted by Juan on October 27, 2009 at 08:20 AM CET #

Juan, thank, I wrote the tutorial because I was invetigating this solution quite a long time and I could not find any resource on that topic.

Posted by Josef Petrak on October 27, 2009 at 08:44 AM CET #

You can find more on page 67 of the book
[2007] - The Definitive Guide to JasperReports (Expert's Voice) - [Apress] - [1590599276].

Posted by helyair on November 06, 2009 at 09:19 AM CET #

Hi Josef,

Thanks for your blog, it has helped most in my learning of Jasper Reports and Jasper Server.

I do have one more question though, on multiple select query type (checkbox). My parameter was at first java.lang.String. Then when I got the error message that it can't be used for multiple query and having reading your article, I change its type to java.util.Collection. Now it shows me this error:

com.jaspersoft.jasperserver.api.JSExceptionWrapper: Report design not valid : 1. Parameter type not supported in query : PackageID class java.util.Collection
(PackageID is my parameter name)

Do you have any idea how to solve this? I didn't find any examples for multiple query (check box).

Thanks.

Posted by Michelle on June 21, 2010 at 02:19 AM CEST #

Michelle, and did you use the different parameter syntaxt? $X{...}

Posted by Josef Petrak on June 21, 2010 at 04:43 AM CEST #

Josef, I did manage to solve my problem. I got confused with all the posts that I've read prior to this that it got all jumbled up. I reviewed my jrxml thoroughly and followed your article and I got it up just how I wanted it to.

Thanks so much!

Now I know it's kinda out of the topic if I ask you this, but do you have any idea how to get my whole input controls interface to appear on my joomla page? :D

Posted by Michelle on June 21, 2010 at 04:51 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Java, PHP and Ruby scripting, Semantic Web research and development, Mac OS X and Apple stuff.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today