ComboBox and Converters

I’m having a hard time with ComboBox’s and Converters.
I’ve searched the forums and what I found and tried doesn’t seem to be working for me.
I’m going from Vaadin 6 to 7 and I’m not liking the Converters at all!
Vaadin 6 I had the Select class and never had to deal with Converters, it just worked.

storeCatRuleId is a BigDecimal. I added my own converter but I keep getting this error:

ERROR MESSAGE: java.math.BigDecimal cannot be cast to java.lang.String

Not sure what I’m doing wrong. Any help would be appreciated.

 public StoreCategoryRuleSelect(String caption){

        BeanContainer<BigDecimal, XxomMooRulesLov> dataSource = new BeanContainer<BigDecimal, XxomMooRulesLov>(XxomMooRulesLov.class);
        dataSource.addAll((new ArrayList<XxomMooRulesLov>()));


//ComboBox creation
        StoreCategoryRuleSelect storeCatRuleField = new StoreCategoryRuleSelect("Store Category");
        storeCatRuleField.setConverter((Converter)new BigDecimalToStringConvertor());
        binder.bind(storeCatRuleField, "storeCatRuleId");

public class BigDecimalToStringConvertor implements Converter<String,BigDecimal> {
    private static final long serialVersionUID = 1921329645985949528L;

    private DecimalFormat df;

    public BigDecimalToStringConvertor() {
        df = new DecimalFormat("#0");

    public BigDecimalToStringConvertor(String decimalFormatPattern) {
        df = new DecimalFormat(decimalFormatPattern);

    public BigDecimal convertToModel(String value, Class<? extends BigDecimal> targetType, Locale locale)
            throws {
        if (value != null) {
            return new BigDecimal(value);    
        return null;

    public String convertToPresentation(BigDecimal value, Class<? extends String> targetType, Locale locale)
            throws {
        if (value != null) {
            return df.format(value.doubleValue());    
        return null;

    public Class<BigDecimal> getModelType() {
        return BigDecimal.class;

    public Class<String> getPresentationType() {
        return String.class;


Mmm, are you sure you need the converter there…? The storeCatRuleId is a BigDecimal and you have set the container’s item ID type also to be BigDecimal, so when you select something with the CB, it’s value will be BigDecimal, so there’s no need for conversion.

That’s what it looks at least with a quick look. I don’t see what would have the String type of the conversion.

Thanks for the reply!
Yeah you make a valid point which lead me to look at why I thought I needed a converter.
I was getting a CommitException that said could not convert BigDecimal to String which lead me to look at the BeanItem and the field I was committing too a String! Realized this was my issue so made changes to the BeanItem to fit my needs and now all is good of course!
Thanks a lot! Some times I just need another set of eyes to help point me down the right path!
Thanks again!