GWT RequestFactory and multiple requests

亡梦爱人 提交于 2019-12-03 00:33:21
Chris Lercher

Yes, it's possible. In your first example, just remove the line

createReq.fire();

When you call createReq2.fire() at the end, then GWT sends both newEmployee and newEmployee2 in one single request (because they were both persisted in the context of your EmployeeRequest "request"). I personally find the semantics a bit strange, but that's just my opinion.

Addendum by Riley: The following syntax is equivalent and is much more intuitive:

    EmployeeRequest request = requestFactory.employeeRequest();
    EmployeeProxy newEmployee = request.create(EmployeeProxy.class);
    newEmployee.setName("Joe!");

    request.persist().using(newEmployee);

    EmployeeProxy newEmployee2 = request.create(EmployeeProxy.class);
    newEmployee2.setName("Sam!");

    request.persist().using(newEmployee2);
    request.fire();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!