In my form I have four fields that should be calculated and the result displayed in the last field called PaymentAmount. I was recommended to use a custom converter for PaymentAmount because I then only needed to have partial refresh on PaymentAmount for onchange event on the other four fields.
This works very good but my problem is that the result is in wrong format.
My code looks like this:
getAsObject()
try {
var transCode = getComponent("TransactionCode").getValue();
var nominal = getComponent("Nominal").getValue();
var price = getComponent("Price").getValue();
var qFactor = getComponent("QuoteFactor").getValue()||1;
var fee1= getComponent("Fee1").getValue()||0;
var fee2= getComponent("Fee2").getValue()||0;
var fee3= getComponent("Fee3").getValue()||0;
var feeTotal = fee1+fee2+fee3;
var paymentAmount = nominal * (price * qFactor);
if(transCode == "Buy") {
paymentAmount+=feeTotal;
} else if(transCode == "Sell") {
paymentAmount -= feeTotal;
} else return 0;
return paymentAmount;
} catch(e){
dBar.error(e);
}
getAsString()
return value.toString();
I have tried to format the result using all available methods and objects in java like: String.format("%.2f", value); but failed.
If I enter my values according to my locale 10000*1,44+1,2 = 14401,2 but the result displayed in PaymentAmount is 14401.2. I'd like it to be displayed according to my locale 14001,2.
If I for instance use the following in getAsString() I get this error:
try {
var val = java.lang.String.format("%.2f",value);
} catch(e) { dBar.error(e); }
com.ibm.jscript.InterpretException: Script interpreter error, line=2, col=28: Java method 'format(string, number)' on java class 'java.lang.String' not found
I can't get the correct data type for value in getAsString().
For you who has seen/commented on my earlier questions I'm stuck with these "localisation issues" once again...
Please advice
/M