RequestFactory persist new object and return the id

72 views
Skip to first unread message

poe

unread,
Dec 8, 2010, 9:23:32 AM12/8/10
to Google Web Toolkit
Hi,

is there a simple way to get the objects id after calling the persist
method?


EmployeeProxy employee = ...request.create(EmployeeProxy.class);
...request.persist().using(employee);
...persistRequest.fire(...) {
onSuccess(Void response) {
// can i somehow get the id from the server-object?
}
}

I've tried altering the persist method to "public String persist()"
instead of "public void persist()" but the requestFactory won't play
along.

Is there a good way to implement that without making a static persist
method?

Daghan

unread,
Jan 5, 2011, 2:37:54 AM1/5/11
to google-we...@googlegroups.com
The documentation says you have to use stableID with is a new Interface they have defined on the client side
They claim that the stableID on the proxy is the same before and after the object is persisted to the database

Note: I am in the process of implementing this but I am not done yet

poe

unread,
Jan 5, 2011, 7:27:57 AM1/5/11
to Google Web Toolkit
I didn' recognize that I've got a private reply on this. So here is
the solution...

if you define your persist method with

public Employee persist() { .... }

and return the new persisted employee object you can modify your
requestFactory interface with

InstanceRequest<EmployeeProxy, EmployeeProxy> persist();

instead of

InstanceRequest<EmployeeProxy, Void> persist();

This way you retrieve the newly persisted object through the
requestfactory.
Reply all
Reply to author
Forward
0 new messages