GXT Version: gxt-1.2.3

The
Code:
read()
method of BeanModelReader inappropriately assumes that all beans are of the same concrete type as the bean residing at index 0 of the list:

Code:
BeanModelFactory factory = BeanModelLookup.get().getFactory(beans.get(0).getClass());
This causes a problem when the List contains beans of different concrete types of a common interface, since the BeanModelFactory will return a wrapper for the concrete type and not the interface.

A fix for this would be to retrieve the BeanModelFactory for each individual bean in the collection:

Code:
public ListLoadResult<ModelData> read(C loadConfig, Object data) {

        if (data instanceof List) {
            List<Object> beans = (List) data;

            if (beans.size() > 0) {
                ArrayList<BeanModel> beanModelList = new ArrayList<BeanModel>();
                for (Object bean : beans) {
                    BeanModelFactory factory = BeanModelLookup.get().getFactory(bean.getClass());
                    if (factory == null) {
                        throw new RuntimeException("No BeanModelFactory found for " + beans.getClass());
                    }
                    BeanModel model = factory.createModel(bean);
                    beanModelList.add(model);
                }
                return newLoadResult(loadConfig, (List)beanModelList);
            }
            return newLoadResult(loadConfig, (List) beans);

        } else if (data instanceof ListLoadResult) {
            ListLoadResult result = (ListLoadResult) data;
            List beans = result.getData();
            if (beans.size() > 0) {
                List<BeanModel> converted = new ArrayList<BeanModel>();
                for (Object bean : beans) {
                    BeanModelFactory factory = BeanModelLookup.get().getFactory(bean.getClass());
                    if (factory == null) {
                        throw new RuntimeException("No BeanModelFactory found for " + bean.getClass());
                    }
                    BeanModel beanModel = factory.createModel(bean);
                    converted.add(beanModel);
                }
                beans.clear();
                beans.addAll(converted);
            }
            return (ListLoadResult) data;
        } else {
            throw new RuntimeException("Error converting data");
        }
    }