我有一个要填充的 CellList AsyncDataProvider
:
@UiField(provided = true)
CellList<PlayerDataEntity> friendCellList;
@Inject
FriendListViewImpl(FriendListController controller) {
friendCellList = new CellList<PlayerDataEntity>(new PlayerCell());
initWidget(uiBinder.createAndBindUi(this));
// if we don't set the row data to empty before trying to get the real data,
// the empty list widget will never appear. But if we do set this,
// then the real data won't show up.
friendCellList.setRowData(Lists.<PlayerDataEntity>newArrayList());
new AsyncDataProvider<PlayerDataEntity>() {
@Override
protected void onRangeChanged(final HasData<PlayerDataEntity> display) {
rpcService.getPlayers(new AsyncCallback<List<PlayerDataEntity>>() {
@Override
public void onSuccess(List<PlayerDataEntity> result) {
display.setRowData(0, result);
}
});
}
}.addDataDisplay(friendCellList);
friendCellList.setEmptyListWidget(new Label("No friends found"));
}
如果我最初没有将行数据设置为空列表,那么如果 RPC 服务返回空列表,则空列表小部件将不会显示。但是,如果我最初将行数据设置为一个空列表,并且 RPC 返回一个非空列表,那么该数据将不会显示在小部件中。
CellList
我一定是误解了API 的某些方面。我究竟做错了什么?