Numberfield (Vaadin 8)

Hi all,
I have a problem with the add-on on NumberFields. Version 0.2.0
I have the following settings:

    setLocale(Locale.GERMANY);
    setDecimalPrecision(2);
    setDecimalSeparator(',');
    setGroupingSeparator('.');
    setGroupingUsed(true);
    setDecimalSeparatorAlwaysShown(true);
    setMinimumFractionDigits(2);
    setValue(0.0);
    setValueChangeMode(ValueChangeMode.BLUR);

Which leads to numbers like 1.567,03€

Now, the use case is, that this is a price for 100 items and I need to calculate the price for one item. The one item
needs to be specific to at least 4 digits after the “,” so lets say from the example above, the each piece would cost
15,6703€.
I bind the Numberfield (nfEkPreis) like this to an entity:
binder.forField(nfEkPreis).withConverter(NumberField.getConverter(“Conversion error”))
.bind(WEScheinEntity::getEKPreis, WEScheinEntity::setEKPreis);

and added a valuechangelistener to recalculate the item price when the amount or total price is changed.

private void calcEkPreis() {

    Double dAmount = new Double(nfAmount.getValue());

    Integer iAmount = dAmount.intValue();

    Double totalPrice = new Double(totalPrice.getValue());

    if (totalPrice > 0.0 && iAmount > 0) {
        Double sEkPreis = Util.round(totalPrice / iAmpint).doubleValue(); 
        nfEkPreis.setValue(sEkPreis);
    }
}

Now, if the calculated price is : 0,123€ the NumberField is set with 0.123 or if the price is 14,00€ the NumberField is set with 14.0
If the calculated price is 1,123€ it is set to 1,123 and if it is 14,01€ it is set to 14,01.

So, the “,” and “.” is not set correctly, because, the conversion with 0.123 makes the item price aftern an update to 123,00€ which is wrong.
It should alway set the “,” as requested via setDecimalSeparator(‘,’);

Any help?
Peter

I don’t know the add-on so can’t talk about that, but you seem to be using a converter that comes with the component binder.forField(nfEkPreis).withConverter(NumberField.getConverter(“Conversion error”)).

That converter does the representation and might lead to an unwanted output. You could build your own converter that you put there and it does the exact comma and decimal count and currency symbol. There might be a readymade converter that has

There might be a readymade NumberFormatter which you can intialize with a pattern also. Something like
NumberFormat nf = NumberFormat.getInstance();
withConverter(new NumberConverter(“%,4f€”));
patter is use comma, use four decimals, add euro sign to the end.