GWT:RequestFactory和ListDataProvider类型错误
我正在尝试使用RequestFactory创建一个通用方法来获取一些数据。 我有一个getData方法,它在请求时执行fire,以获得项目列表(泛型) 问题是,当我尝试将返回的列表arg0分配给我的ListDataProvider时,我得到一个类型错误GWT:RequestFactory和ListDataProvider类型错误,gwt,requestfactory,Gwt,Requestfactory,我正在尝试使用RequestFactory创建一个通用方法来获取一些数据。 我有一个getData方法,它在请求时执行fire,以获得项目列表(泛型) 问题是,当我尝试将返回的列表arg0分配给我的ListDataProvider时,我得到一个类型错误 private ListDataProvider<T> dataProvider; . . . . public <T> void getData(Request<List<T>> spe
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>
}
私有ListDataProvider数据提供者;
.
.
.
.
public void getData(请求特定请求){
specificRequest.fire(新接收器(){
@凌驾
成功时公共无效(列表arg0){
分配数据提供者(arg0);
}
});
返回;
}
公共数据提供程序(列表arg0){
this.dataProvider.setList(arg0);
//类型ListDataProvider中的方法setList(List)不可用
适用于参数(列表)
this.dataProvider=newlistdataprovider(arg0);
//类型不匹配:无法从转换
com.google.gwt.view.client.ListDataProvider到
com.google.gwt.view.client.ListDataProvider
}
如何使用从arg0获取的数据,以便将其分配给我的ListDataProvider?如果在声明dataProvider时未获得错误,则类型t在类声明中定义为参数。
如果是这样,您应该从方法声明中删除
祝你好运 你犯了什么错误?始终使用代码提供错误堆栈跟踪。当我使用:this.dataProvider.setList(arg0)时,错误为:public void assignDataProvider(List arg0){this.dataProvider.setList(arg0);this.dataProvider=new ListDataProvider(arg0);};当我使用时,类型ListDataProvider中的方法setList(List)不适用于参数(List):this.dataProvider=new ListDataProvider(arg0);类型不匹配:无法从com.google.gwt.view.client.ListDataProvider转换为com.google.gwt.view.client.ListDataProvider谢谢我从方法声明中删除了