Getting my head around this simple problem in JasperSoft Sudio - Variables to Parameters

Hi Guys,

I am building this test report in Jaspersoft Studio and I am hoping that some of you will be able to help me or point me to material / manuals / tutorials that would help me with this.

What I want to do is qute simple, and dead easy in a spreadsheet but I am struggling with it in JasperSoft Studio, here is what i want to achieve:

I want the end user to do the following:

1. Select from dropdown menu value 1 (I have simple table with two columns -  value1 and description, I want the users to be able to use description to select value1) Value1 is string.

2. Select from dropdown menu value 2 (same as above, two columns - value 2 and description. Select the value by its description) Value2 is string.

3. When both values are selected I want to concatenate them to form one code. To give you an example, value(s)1 look like: ab-c1-d1 and value(s)2 look like: ef-gh-00 now I want to concatenate them to form one line of code with extra hyphen between them to form this: ab-c1-d1-ef-gh-00

4. That unique code corresponds to a value in a third table that I want to display.


I have managed to do half of the job already, I can select from all tables and display the corresponding values but there is no connection between them as I want.


I hope I am clear enough, and thank you in advance for any help! I am stuck with this for some time and the info on the net is scarce, unless I am looking for wrong things.

All the best to you all




pawelkosi's picture
Joined: Jan 14 2014 - 9:07am
Last seen: 5 years 1 week ago

3 Answers:

Hi Pawel, what you want is to add a variable:
Where your variable expression is $V{value1}+$V{value2} or $F{value1}+$F{value2} or $P{value1}+$P{value2}

This will give you the concenated value (3)

I hope this helps. Is this on the Jasperserver?


sjoerd.jump's picture
Joined: Oct 29 2012 - 2:39pm
Last seen: 11 months 1 week ago

Hi Sjored


Thank you very much for answering! Yes that was a part of it. Here is where I am at the moment:

1. You get the prompt for the value from table1 and table2, and then the both values get concatenated in variable1. So basically I have the concatenated code as I needed.

2. Now I want to pass that variable to the table dataset so the table can display the relevant record for that code. Unfortunately this is where I have hit the problems.

I have few questions regarding this, if you will be willing to answer them:

1. Is there a way to copy or move the output (or end result) of variable into the parameter? I know I can pass parameters to the table, but passing variables didnt work.

2. I have found someone elses question here asking about similar problem and the answer was to do the relevant concatenation within the parameter 'Default Expression Field' instead of using variable. But when I try to do that I get errors, my open parameters do not show fields or variables in expression editor only other parameters.

This is the URL of that answer:

Where part of the answer is:

"In your case you will need to do the calculation of your dates in Parameters using the parameter default expression property."

3. Then I have found another answer, again similar to mine where there was talk about scriplets:

"You need scriptlet magic.

First create a scriptlet to do the value passing. This example takes an Integer variable and sets a String parameter, then returns the String contents of the parameter so it can be displayed in a text field:"


Do I really need scriplets to pass value from variable to parameter? Is there any other way of doing it?

Thanks for your answer once again!


pawelkosi's picture
Joined: Jan 14 2014 - 9:07am
Last seen: 5 years 1 week ago

oh and Yes I will be deploying this to JasperReports Server.

pawelkosi - 8 years 6 months ago
You might try to create a Parameter with variable expresssion $V{value1+2}
then, in your query select * from table where var1 = $P{parameter1}

This you export to jasperserver.
sjoerd.jump's picture
Joined: Oct 29 2012 - 2:39pm
Last seen: 11 months 1 week ago