我似乎对 GWT 异步调用的工作方式和/或小部件在收到回调后如何更新存在一些根本性的误解。
我已经创建了两个接口以及实现,它们似乎正在相互通信。我根据在使用 eclipse 调试器单步执行时观察到的合理外观数据做出此声明:result
下面的 onSuccess 方法中的变量包含我期望的内容,并且我尝试填充的网格最终被results
退出时的数据填充从循环。但是,当onSuccess
调用返回时,我的 GUI 中不会根据uhpScrollPanel.setWidget(uhpGrid)
调用显示任何网格,并且不会引发任何类型的异常。
我一定是忽略了一些明显的东西,有没有人知道在哪里看?
final ScrollPanel uhpScrollPanel = new ScrollPanel();
uhpVert.add(uhpScrollPanel);
uhpScrollPanel.setSize("100%", "100%");
//build and populate grid
UpdateHistoryServiceAsync uhpService = UpdateHistoryService.Util.getInstance();
uhpService.getUpdateHistory(new AsyncCallback<List<UpdateHistoryEntryBean>>() {
public void onFailure(Throwable caught) {
System.out.println("OnFailure");
caught.printStackTrace();
final Label uhpErrorLabel = new Label("Server Unable to Grab History...");
uhpScrollPanel.setWidget(uhpErrorLabel);
uhpErrorLabel.setSize("100%", "100%");
}
public void onSuccess(List<UpdateHistoryEntryBean> result) {
int length = result.size();
final Grid uhpGrid = new Grid();
uhpScrollPanel.setWidget(uhpGrid);
uhpGrid.setBorderWidth(1);
uhpGrid.setSize("100%", "100%");
uhpGrid.resize(length, 3);
int i = 0;
for (UpdateHistoryEntryBean entry : result) {
uhpGrid.setText(i, 0, String.valueOf(entry.getSourceId()));
uhpGrid.setText(i, 1, entry.getTitle());
uhpGrid.setText(i, 2, entry.getBody());
i++;
}
}
});