在使用编辑器进行更改后,我无法弄清楚如何更新我的celltable。如果我可以获得已编辑的代理,那么我可以使用dataprovider来更新我的celltable。
public void saveCampaign() {
driver.flush();
// the problem. proxy at this point should have the new values?....
context.persist().using(proxy).fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
showListView();
}
});
}
.using(代理)中的代理不包含对编辑器所做的更改。但是,服务器上的持久方法获取更新的值。如果我从服务器重新加载数据,我会得到正确的值到celltable。
public void editCampaign(CampaignProxy proxy) {
this.proxy = proxy;
if (proxy != null) {
context = AEHOME.requestFactory.campaignRequest();
showEditView();
}
}
private void showEditView() {
driver.initialize(eventBus, AEHOME.requestFactory, editView);
driver.edit(proxy, context);
deckPanel.showWidget(deckPanel.getWidgetIndex(editView));
}
代理在列表视图中设置:configurationPageView.proxy = selectionModel.getSelectedObject();
任何建议都将不胜感激。谢谢。
答案 0 :(得分:2)
您可以通过执行以下操作来更改请求的构建方式:
private void showEditView() {
driver.initialize(eventBus, AEHOME.requestFactory, editView);
driver.edit(proxy, context);
// Set up method invocation and callback in advance
context.persist().using(proxy).to(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
showListView();
}
}););
deckPanel.showWidget(deckPanel.getWidgetIndex(editView));
}
public void saveCampaign() {
driver.flush().fire();
}
在GWT 2.4中,可以保留当前的代码组织并使用RequestContext.append()
:
public void saveCampaign() {
// Returns the context passed to edit()
RequestContext ctx = driver.flush();
// append() is generic and returns the type returned by myProxyContext();
ctx.append(requestFactory.myProxyContext()).persist().using(proxy).fire(....);
}