【发布时间】:2012-10-30 13:49:31
【问题描述】:
是否有人可以解决我为什么要通过包含 ListStoreEditor 子编辑器的 GXT 网格将空值保存到服务器实体上的 OneToMany 列表?
我已经按照 Sencha 示例 GridBindingExample 进行了操作。 http://www.sencha.com/examples/#ExamplePlace:gridbinding
public class MyEditor implements IsWidget, Editor<FooProxy> {
interface Binder extends UiBinder<Widget, MyEditor> {}
private static Binder uiBinder = GWT.create(Binder.class);
public interface Driver extends SimpleBeanEditorDriver<MyProxy, MyEditor> {}
private Driver driver = GWT.create(Driver.class);
private ListStore<BarProxy> store;
ListStoreEditor<BarProxy> items;
@Ignore
@UiField(provided = true)
Grid<BarProxy> grid;
@Ignore
@UiField
ChildEditor childEditor;
@Override
public Widget asWidget() {
MyProperties props = GWT.create(MyProperties.class);
this.store = new ListStore<BarProxy>(props.key());
List<ColumnConfig<BarProxy, ?>> columns = new ArrayList<ColumnConfig<BarProxy, ?>>();
columns.add(new ColumnConfig<BarProxy, String>(props.itemName(), 300, "MyColumn"));
this.grid = new Grid<BarProxy>(store,new ColumnModel<BarProxy>(columns));
items = new ListStoreEditor<BarProxy>(store);
Widget widget = uiBinder.createAndBindUi(this);
driver.initialize(childEditor);
childEditor.getCreateButton().addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
RequestContext context = factoryProvider.get().barRequest();
BarProxy entity = context.create(BarProxy.class);
entity.setName("Eugene Qtest");
entity.setAge(45);
driver.edit(entity);
store.add(driver.flush());
}
});
return widget;
}
}
public class ChildEditor implements IsWidget, Editor<BarProxy> {
interface Binder extends UiBinder<Widget, ChildEditor> {}
private static Binder uiBinder = GWT.create(Binder.class);
@UiField
TextButton createButton;
@Override
public Widget asWidget() {
return uiBinder.createAndBindUi(this);
}
public TextButton getCreateButton() {
return createButton;
}
}
在我的代码中的上层演示者中,我正在调用:
RequestContext req = editorPresenter.getDriver().flush();
req.fire();
这确实保存了 GWT 编辑器捕获的所有数据元素。在我的数据库中,它确实在上面的代码中为网格创建了行,但是所有的值都是空的,所以当 RequestContext 触发时,持久化会在网格中返回一个空行。因此,没有外键可以将 OneToMany 关系中的实体关联回其父实体。
另外,我查看了对服务器的 JSON 请求和响应,看起来没有任何值正在实体中发送。它可能被混淆了,但它看起来好像其他值是纯文本,所以我认为代理实体值甚至没有被传递。
任何帮助都会很棒!谢谢
【问题讨论】:
标签: gwt gxt gwt-editors