PDA

View Full Version : [FIXED] List.add(List) in BeanModelReader



sdc
16 Jul 2008, 6:15 AM
In last SVN build, lines 38-47 :

ListLoadResult result = (ListLoadResult) data;
List beans = result.getData();
if (beans.size() > 0) {
BeanModelFactory factory = BeanModelLookup.get().getFactory(beans.get(0).getClass());
if (factory == null) {
throw new RuntimeException("No BeanModelFactory found for " + beans.get(0).getClass());
}
List converted = factory.createModel(beans);
beans.clear();
beans.add(converted);If you do that, the loader try to convert a list to a ModelData (ClassCastException). You should do instead (last line) or :
beans.addAll(converted);You can reproduce the issue with the explorer demo by replacing the ExplorerService.getCustomers return type from List<Customer> to ListLoadResult<Customer>

sdc
16 Jul 2008, 6:20 AM
By the way, I see you have :

In ExplorerServiceAsync :

public void getCustomers(AsyncCallback<ListLoadResult<Customer>> callback);In ExplorerService :

public List<Customer> getCustomers();Can you shortly explain me how does it work (how is List implicitly converted to ListLoadResult) ? Is it with deferred binding ? GWT serialization mechanism ?

darrellmeyer
16 Jul 2008, 9:52 AM
beans.add(converted);Yes, that is a bug and has been fixed.


Can you shortly explain me how does it work (how is List implicitly
converted to ListLoadResult) ? Is it with deferred binding ? GWT
serialization mechanism ?The List is never converted to ListLoadResult by GWT. It looks like the GWT code does not enforce the type of data in the callback. From a GXT perspective, the reason this works is that the result is never assigned to ListLoadResult. The data proxy simply passes the data to the reader which checks the type of the data, which is List and then creates a new BaseListLoadResult instance.

sdc
16 Jul 2008, 11:50 PM
Thanks. :)