Converter for Field with MultiSelect

Hi !

I use a TwinColSelect in my project and I’m not able to create the corresponding converter, here is an extract to show you where I’m stucked :

[code]
public class ProductMultiSelectConverter implements Converter<Collection, Collection> {
@Override
public Collection convertToModel(Collection objects, Class<? extends Collection> aClass, Locale locale) throws ConversionException {
// this part is ok
}

@Override
public Collection<Object> convertToPresentation(Collection<Product> products, Class<? extends Collection<Object>> aClass, Locale locale) throws ConversionException {
    // this part is ok
}

@Override
public Class<Collection<Product>> getModelType() {
    // I don't know how to implement this part
}

@Override
public Class<Collection<Object>> getPresentationType() {
    // I don't know how to implement this part
}

}
[/code]To sum up, I don’t know how to retrieve the class of the model type and of the presentation type because of the nested generics Class<Collection>. Maybe it’s more a java oriented question than a Vaadin one but If you have any example, it would really help me.

I have seen the code sample when using JpaContainer :

return select.getPropertyDataSource().getType(); but I’m not using JpaContainer in my project , I’m using LazyQueryContainer and unfortunately it does’nt work in my case

Thanks in advance for your help

Have you tried this?

@SuppressWarnings("rawtypes")
    public class ProductMultiSelectConverter implements
            Converter<Collection, Collection> {
        @Override
        public Collection<Product> convertToModel(Collection objects,
                Class<? extends Collection> aClass, Locale locale)
                throws ConversionException {
            return null;
        }

        @Override
        public Collection<Object> convertToPresentation(Collection products,
                Class<? extends Collection> aClass, Locale locale)
                throws ConversionException {
            return null;
        }

        @Override
        public Class<Collection> getModelType() {
            return Collection.class;
        }

        @Override
        public Class<Collection> getPresentationType() {
            return Collection.class;
        }
    }