I'm trying to make a generic method to get some data with RequestFactory. I have a method getData that executes fire on a Request in order to get a list of items(generics) The problem is when I try to assign the returned List arg0 to my ListDataProvider I get a type error.
private ListDataProvider<T> dataProvider;
.
.
.
.
public <T> void getData(Request<List<T>> specificRequest) {
specificRequest.fire(new Receiver<List<T>>() {
@Override
public void onSuccess(List<T> arg0) {
assignDataProvider(arg0);
}
});
return ;
}
public <T> void assignDataProvider(List<T> arg0) {
this.dataProvider.setList(arg0);
//The method setList(List<T>) in the type ListDataProvider<T> is not
applicable for the arguments (List<T>)
this.dataProvider= new ListDataProvider<T>(arg0);
//Type mismatch: cannot convert from
com.google.gwt.view.client.ListDataProvider<T> to
com.google.gwt.view.client.ListDataProvider<T>
}
How can I use the data I get from arg0 so I can assign it to my ListDataProvider?
If you don't get error on the declaration of dataProvider type T is defined as a parameter in a class declaration.
If so you should remove from method declarations.
Good luck!