如果参数在Jasper报告的TextField中有三个以上,则如何将参数转换为描述

时间:2012-05-03 23:33:12

标签: jasper-reports

报告中有3个参数。我想转换TextField中描述中的所有id参数。

The first parameter is $P{address}
if $P{address} = 1 then "Port Garden"
else if $P{address} = 2 then "pangsa maju,indah"
else if $P{address} = 3 then "eastern mouth"
else null

The second parameter is the $P{city}
if $P{city} = 1 then "Gosa"
else $P{city} = 2 "Marang"
else if $P{city} = 3 "kuala seberang"
else null

The third parameter is the $P{country}
if $P{country} = 198 then "China"
else if $P{country} = 234 then "Bangladesh"
else if $P{country} = 390 then "Sri Lanka"
else null

当我键入参数时,我想要在Textfield中更改描述的所有参数。

For example. "Information for company the address is $P{address}=1, city is $P{city}=1 and country is $P{country}=198".
The result is "Information for the company address is Port garden, city is Gosa and country is China.

有人知道这个吗?。:(

1 个答案:

答案 0 :(得分:1)

将值硬编码到报告中就像这样奇怪。这可能是一个坏主意。

但尽管是一个坏主意......但这并不难。使用这样的东西。创建一个名为$ P {Country_Name}的参数。使用三元运算符(多次)给它一个默认值,如下所示:

$P{country}==198 ? "China" : 
  $P{country}==234 ? "Bangladesh" : 
    $P{country}==390 ? "Sri Lanka" : "somewhere else"