Jasper reports 如果参数在Jasper报告的文本字段中有三个以上,如何将参数转换为描述

Jasper reports 如果参数在Jasper报告的文本字段中有三个以上,如何将参数转换为描述,jasper-reports,Jasper Reports,我在报告中有3个参数。我想转换我文本字段中描述中的所有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

我在报告中有3个参数。我想转换我文本字段中描述中的所有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.

有人知道吗?:(

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

尽管这是个坏主意……但并不难做到。使用类似的方法。创建一个名为$p{Country_Name}的参数。使用三元运算符(多次)为其指定默认值,如下所示:

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

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

尽管这是个坏主意……但并不难做到。使用类似的方法。创建一个名为$p{Country_Name}的参数。使用三元运算符(多次)为其指定默认值,如下所示:

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

我尝试过你的解决方案,但它不起作用。你能检查一下我的代码有什么问题吗?($P{Country_Name}在我的例子中有它的默认值基于$P{Country}。你有$P{pd_id}在默认值中引用它自己。这不起作用。我不明白你对$P{Country_Name}和$P{Country}的意思是什么?我很困惑。为什么你要放两个参数。我只想要一个参数和一个描述。怎么做?你能给我更多的例子吗?你能修改我的代码,让我知道我的错误在哪里吗?当我写“创建一个名为$P{Country{U Name}的参数。”我的意思是,“创建一个名为$P{Country{U Name}的参数。”我不是这个意思“向现有参数添加默认值。”您有一个ID为的整数,需要第二个参数将此ID转换为适当的字符串。我尝试了您的解决方案,但无效。您能检查我的代码有什么问题吗?:($P{Country\u Name}在我的示例中有基于$P{Country}的默认值。您有$P{pd\u ID}在默认值中引用自身。这不起作用。我不明白$P{Country_Name}和$P{Country}的意思。我很困惑。为什么要放两个参数。我只想要一个参数和一个描述。如何做?你能给我更多的例子吗?你能修改我的代码以便我知道我的错误在哪里吗?当我写的时候,“创建一个名为$P{Country\u Name}的参数。我的意思是“创建一个名为$P{Country\u Name}的参数”。我的意思不是“为现有参数添加一个默认值”。您有一个ID为的整数,需要第二个参数将此ID转换为适当的字符串。