Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GWT请求工厂+;编辑器框架重新加载关联实体_Gwt_Gwt2_Requestfactory_Gwt Editors - Fatal编程技术网

GWT请求工厂+;编辑器框架重新加载关联实体

GWT请求工厂+;编辑器框架重新加载关联实体,gwt,gwt2,requestfactory,gwt-editors,Gwt,Gwt2,Requestfactory,Gwt Editors,我将GWT2.5rc1与RequestFactory和编辑器框架一起使用。保存具有关联模型的实体时,服务器的定位器将在保存之前重新加载关联模型。因此,客户机中的任何更改都是重写的。例如: @ProxyFor(value=Foo.class, locator=FooLocator.class) public interface FooProxy extends EntityProxy { void setBar(BarProxy bar); BarProxy getBar(); } @

我将GWT2.5rc1与RequestFactory和编辑器框架一起使用。保存具有关联模型的实体时,服务器的
定位器将在保存之前重新加载关联模型。因此,客户机中的任何更改都是重写的。例如:

@ProxyFor(value=Foo.class, locator=FooLocator.class)
public interface FooProxy extends EntityProxy {
  void setBar(BarProxy bar);
  BarProxy getBar();

}

@ProxyFor(value=Bar.class, locator=BarLocator.class)
public interface BarProxy interface EntityProxy {
  ...
}

// The save method implemented in an Activity.
// Invoked when the editor's save button is clicked.
public void onSave() {
  // driver is a RequestFactoryEditorDriver
  FooRequest request = (FooRequest) driver.flush();
  request.save(entity).fire(myReceiver);
}

// The service on the server that saves the two entities.
public class FooService {

  public Foo save(Foo foo) {
    barDao.save(foo.getBar()); // Bar has been reloaded via the BarLocator and all changes lost
    fooDao.save(foo);
    return foo;
  }
}
在服务器上,将调用
BarLocator.find(…)
方法,该方法将重新加载Bar实例并覆盖对传入Bar实例所做的任何更改

日志输出示例:

FooLocator loading Foo
setBar called
BarLocator loading Bar
save called

最后三行都是指从DB加载的条;我从来没有在我的任何定位器或服务代码中看到更改的条。

您在
Foo
上有
setBar
吗?我一直在玩这个。Foo是否应该返回一个完全混合的Foo?换句话说,酒吧应该存在吗?当前的fooolocator.find实现返回带条集的Foo。问题出在save()上,傻瓜操作器调用setBar()。当您将两个对象(foo和bar)发送到服务器时,它将
找到它们(或
值代理创建
),调用属性设置器(包括
setBar
),然后只调用服务方法;因此,如果getter/setter是字段的简单访问器,那么
foo.getBar()
应该从
Locator
加载的
Bar
中获取您的属性。那么我是否无法保存对象图?我想说的是,您的代码应该可以工作。但它可能失败的原因有很多(不使用视图模式中的开放会话,做的不仅仅是在setters中分配一个字段,等等)