Restrict Multiselect Input Control Values in Jaspersoft

Posted on by By admin, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 3

How to restrict Multiselect input control values in Jaspersoft 

This blog will teach the reader , how to restrict multiselect input control values in jasper without hampering the performance .

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Grab The 30 Days Free Trail

DB : Postgres (foodmart)

Table : customer

Reporting tool : iReport

Server : Jasperserver 5.6

I/P Parameter : country

Requirement : Get All the informations from customer table where country name is either USA or Mexico or Canada

Condition :

  1. you can not select more than 2 value in “country” input parameter
  2. if more than 2 values are selected in “country” input parameter then the main report query should also not get executed. This will unnecessarily hamper the performance.

Solution :

  1. create multiselect input control named as “country”

select distinct country from customer

  1. create a sub report which will display all the informations from customer table on selection of “country” parameter

and give its print when expression as :

$P{country}.size() <= 2

  1. create a text box in the header , write a message init as :

“You can not select more than 2 values in country parameter”

And give its print when expression as :

$P{country}.size() > 2

  1. in the sub report , query will be :

select * from customer

where $X{IN,country,country}

limit 20

  1. publish the report on jasper server.

O/P

# 1 : when 2 values selected in country parameter

lenlt2#2 : when more than 2 values selected in country parameter

lengt3

Thanks,

Rupam Bhardwaj

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Hi,

Can you please tell me where to put “$P{country}.size() <= 2" condition

Hi Tapan,

Go to the subreport Properties section . There you will get one Property called “Print when expression” . Here You have to put “$P{country}.size() <= 2".

For your reference I have attached screenshot below :

you need to put that condition on sub report’s “print when expression”.