I followed the
Editor example using RequestFactoryEditorDriver for RF-driven persistence. But it doesn't work for me.
When I call
public class EmployeeEditor extends Composite implements Editor<EmployeeProxy>
the model data is transfered into the Composite and all UiBinder fields get their values.
I use this code
void edit(EmployeeProxy employee) {
driver.initialize(cf.getRF(), employeeEditor);
final EmployeeReqCtx reqCtx = cf.getRF().employeeReqCtx();
driver.edit(employee, reqCtx);
cf.getLogger().log(Level.INFO, "driver.isDirty: " + driver.isDirty());
}
to achieve this.The driver
interface Driver extends RequestFactoryEditorDriver<EmployeeProxy, EmployeeEditor>
is clean at this point. As soon as I call
void save() {
cf.getLogger().log(Level.INFO, "driver.isDirty: " + driver.isDirty());
final RequestContext reqCtx = driver.flush();
if (driver.hasErrors()) {
cf.getLogger().log(Level.INFO, "DRIVER HAS ERRORS.");
}
cf.getLogger().log(Level.INFO, "driver.isDirty: " + driver.isDirty());
// Send the request
reqCtx.fire(new Receiver<Void>() {
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> errors) {
cf.getLogger().log(Level.SEVERE, "ERRORS DETECTED ON THE SERVER" + errors.size());
}
@Override
public void onSuccess(Void response) {
cf.getLogger().log(Level.SEVERE, "SUCCESS!");
cf.getLogger().log(Level.INFO, "driver.isDirty: " + driver.isDirty());
}
});
cf.getLogger().log(Level.INFO, "driver.isDirty: " + driver.isDirty());
}
the driver becomes dirty and the "SUCCESS!" message appears. So the entity has been persisted at this point? However the subsequent log message in onSuccess() reports that the driver is still dirty. And when I call save() again, the
Caused by: java.lang.IllegalStateException: A request is already in progress
exception is thrown.
My persistence framework is Objectify and the corresponding RequestFactory using JUnit tests are working and modify the entities as expected.