-
1. Re: Standart Errai bind doesn't support empty values for numeric types
csa Jan 29, 2014 12:20 PM (in response to arumad)1 of 1 people found this helpfulHi Olexandr,
Yes the built-in converters for BigDecimal and BigInteger didn't handle that case. They do now in the latest 3.0-SNAPSHOTs. If you can't upgrade you can always define your own binding specific converter (@Bound(converter=MyBigDecimalConverter.class)) or register a default converter for that type. Then you don't have to provide it at each binding.
So, you could simply add this to a client package of your app:
@DefaultConverter public class BigDecimalConverter implements Converter<BigDecimal, String> { @Override public BigDecimal toModelValue(String widgetValue) { return (widgetValue == null || widgetValue.isEmpty()) ? null : new BigDecimal(widgetValue); } @Override public String toWidgetValue(BigDecimal modelValue) { return (modelValue == null) ? "" : modelValue.toString(); } }
Cheers,
Christian
-
2. Re: Standart Errai bind doesn't support empty values for numeric types
arumad Jan 30, 2014 1:27 AM (in response to csa)Thanks.
Why only BigInteger and BigDecimal are made nullable in 3.0-SNAPSHOT?
Empty values for other types would still fail to reach model.
-
3. Re: Standart Errai bind doesn't support empty values for numeric types
csa Jan 30, 2014 12:01 PM (in response to arumad)I actually thought I did but you're right I didn't. It should be OK now. However, Boolean.parseBoolean("") is OK as it returns false. Everything else should default to null now.
Thanks!