GWT:RequestFactory和ListDataProvider类型错误

时间:2012-04-10 05:19:13

标签: gwt requestfactory

我正在尝试使用RequestFactory创建一些通用方法来获取一些数据。 我有一个方法getData,它在Request上执行fire以获取项目列表(泛型) 问题是当我尝试将返回的List arg0分配给我的ListDataProvider时,我得到了一个类型错误。

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> 
} 

如何使用从arg0获取的数据,以便将其分配给ListDataProvider?

1 个答案:

答案 0 :(得分:0)

如果在dataProvider声明中没有出错,则T类被定义为类声明中的参数。
如果是这样,您应该从方法声明中删除。

祝你好运!

相关问题