Hi,
I am just playing around with the Editor Framework in combination with RequestFactoryEditorDriver and currently calling RFED.flush() does not update the edited object and I can not see why.
The app is pretty simple and the workflow is:
1.) Create view and initialize RFED
2.) Create a Person on the server datastore (simple hash map and UUID as id)
3.) Fetch the created person from server using the .stableId()
4.) start editing the fetched person
5.) at some point (currently on key up events while editing the persons name) do RFED.flush()
6.) PersonProxy does not contain updated name.
Client Side code:
@Override
public void onModuleLoad() {
//init view
view = new PersonViewImpl();
view.setDelegate(this);
RootPanel.get().add(view);
//init RequestFactory and RFED
requestFactory = GWT.create(AppRequestFactory.class);
requestFactory.initialize(new SimpleEventBus());
driver = view.createDriver();
driver.initialize(requestFactory, view);
//create person on server datastore (hash map)
PersonRequest createRequest = requestFactory.personRequest();
final PersonProxy p = createRequest.create(PersonProxy.class);
createRequest.persist(p);
createRequest.fire(new Receiver<Void>() {
@Override
public void onSuccess(final Void result) {
//fetch created person from server
Request<PersonProxy> findRequest =
(Request<PersonProxy>) requestFactory.find(p.stableId()).with(driver.getPaths());
findRequest.fire(new Receiver<PersonProxy>() {
@Override
public void onSuccess(final PersonProxy foundPerson) {
//start editing fetched person
PersonRequest editRequest = requestFactory.personRequest();
//editPerson = editRequest.create(PersonProxy.class);
editPerson = foundPerson;
editRequest.persist(editPerson);
driver.edit(editPerson, editRequest);
}
});
}
});
}
@Override
public void onDataChanged() {
//try to autosave the changed data
if(driver != null) {
driver.flush();
System.out.println("edited: " + editPerson.getName() + ", " + editPerson.getUuid());
//... clone editPerson and save the clone with a separate request context....
}
}
When I am not editing the fetched person but editing a newly created one (see editPerson = editRequest.create(PersonProxy.class);), it works like expected and editPerson contains the updated name. But this will also create new persons on server side once I will save changes of the person proxy.
What am I missing? I think it shouldn't be much of a difference if the proxy is newly created or fetched from server.
Also you may notice that I do not use the RequestContext returned by driver.flush() because I clone the proxy anyways and save it in background in a separate RequestContext (auto save functionality and that way I am able to continuously edit the proxy while saving it). So in general a SimpleBeanEditorDriver would be enough for editing but I would like to use the getPaths() method of RFED when fetching data from server. Is there an easy way to calculate paths for a SimpleBeanEditorDriver?
Thanks in advance.
-- J.