2012-05-03 5 views
1

レポートに3つのパラメータがあります。私はTextFieldの説明のすべてのidパラメータを変換したいと思います。JasperレポートのTextFieldにパラメータが3つ以上ある場合、パラメータを説明に変換する方法

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 

パラメータを入力すると、テキストフィールドの説明を変更したすべてのパラメータが必要になります。

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

ハードコーディングこのようなレポートに値が奇数である。それはおそらく悪い考えです。

しかし、悪い考えているにもかかわらず... 。それが行うのは難しいことではありません。このようなものを使用する$ P {COUNTRY_NAME}というパラメータを作成し、それをこのように三項演算子(複数回)を使用して、デフォルト値付け:。。。

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

を私はあなたのソリューションを試してきたが、それは動作しません。私のコードに何が問題なのですか?:( –

+0

$ P {Country_Name}は、私の例で$ P {country}に基づいてデフォルト値を持っています。 $ P {pd_id}は、デフォルト値で自身を参照しています。これは動作しません。 – mdahlman

+0

$ P {Country_Name}と$ P {country}の意味は分かりません。私は混乱しています.2つのパラメータを入れたのはなぜですか?1つのパラメータと1つの説明だけが必要です。どのようにすればいいですか?もっと多くのサンプルを表示できます。 –

関連する問題