gpt4 book ai didi

java - 如何使用 Vaadin Flow CallBackDataProvider 修复 'Incompatible Types' 错误

转载 作者:太空宇宙 更新时间:2023-11-04 09:44:58 24 4
gpt4 key购买 nike

我尝试为我的网格创建一个带有 vaadin 流的回调数据提供程序。但当我尝试制作它时,它返回一个不兼容的类型错误。

我已经将代码最小化为最简单的问题版本,但它仍然不起作用,我按照 vaading 流程指南制作了一个,它与我的代码几乎相同:

dataProvider = DataProvider.fromCallbacks(
query -> {
List<Person> people = new ArrayList<>();
return people;
},
query -> {
int i = 0;
return i;
});

这应该可行,但我收到以下错误:

incompatible types: no instance(s) of type variable(s) T,F exist so that com.vaadin.data.provider.CallbackDataProvider conforms to com.vaadin.flow.data.provider.CallbackDataProvider

最佳答案

所有 Vaadin 10+ (Flow) 相关类都位于 com.vaadin.flow 包中。请使用该包中的DataProviderHere是一个代码示例:

import com.vaadin.flow.data.provider.*;

DataProvider<Person, Void> dataProvider = DataProvider.fromCallbacks(
// First callback fetches items based on a query
query -> {
...
return persons.stream();
},
// Second callback fetches the number of items for a query
query -> getPersonService().getPersonCount());

关于java - 如何使用 Vaadin Flow CallBackDataProvider 修复 'Incompatible Types' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55514098/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com