如何在Jasper中格式化以下if / else?

时间:2015-04-28 16:09:29

标签: if-statement groovy jasper-reports

我试图在Jasper中格式化以下if / else并遇到麻烦。这就是我所拥有的,但我的语法错误可以有人帮忙吗?

$F{PAYMENT_METHOD_DATA}  == {"deposit_name":"PayNearMe","is_important":true,"logo":"https:\/\/nj-cdn-casino.ballyinteractive.com\/cms\/V3\/Deposit-Methods\/icon-Paynearme.png"} ? "PayNearMe" :
$F{PAYMENT_METHOD_DATA} ==  {"deposit_name":"ACH (Optimal)","withdrawal_name":"ACH (Optimal)","display_order":"101","is_important":true} ? "ACH" :
$F{PAYMENT_METHOD_DATA} ==  {"deposit_name":"wire transfer","withdrawal_name":"wire transfer","display_order":"42","is_important":true} ? "Wire Transfer" :   
$F{PAYMENT_METHOD_DATA} ==  {"deposit_name":"Personal check","withdrawal_name":"Personal check","display_order":"6","is_important":true} ? "Personal Check" :
$F{PAYMENT_METHOD_DATA} ==  {"deposit_name":"Cashier''s check","withdrawal_name":"Cashier''s check","display_order":"7","is_important":true} ? "Cashiers Check": "Cash"

1 个答案:

答案 0 :(得分:1)

三元运算符应为like

condition ? execute true code : execute false code

jasper条件应该是,

$F{PAYMENT_METHOD_DATA}  == "deposit_name"?"PayNearMe":"PayMe"

如果你想检查多个条件,那么你应该写如,

$F{PAYMENT_METHOD_DATA}  == "deposit_name"?($F{PAYMENT_METHOD_DATA}  == "deposit_name_other"?"PayNearMeYes":"PayMeYes"):"PayMe"