how can I bind a BigDecimal member variable to a TextField that is created in a BeanFieldGroup?
class MyBean {
BigDecimal amount;
}
BeanFieldGroup binder = new BeanFieldGroup<MyBean>(MyBean.class);
binder.buildAndBind("Amount:", "amount");
TextField amount = (TextField) binder.getField("amount");
//how can I tell the amount field that it should be of type BigDecimal.cass?
There was a problem with this at least with 7.0, and in 7.1 there is no generic StringToNumberConverter, but at least it should be easy to write your own StringToBigDecimalConverter as a subclass of AbstractStringToNumberConverter and set it explicitly or use a custom ConverterFactory (see the javadoc of DefaultConverterFactory).
Actually, StringToNumberConverter still exists in 7.1 (it’s removed in 7.2). It’s broken, however, along with DefaultFieldFactory which returns instances of StringToNumberConverter for any Number subclasses that don’t have a specific converter - even though it can’t possibly handle most of them. Please see
ticket #12225 .
StringToBigDecimalConverter will be added in 7.2; in the meantime, you’ll have to implement your own, like Henri said.