Friday, January 13, 2012

Re: RequestFactory: Get entity ID on success of persist



On Thursday, January 12, 2012 3:24:38 PM UTC+1, Tapomay Dey wrote:
Hi,
I am using following code.

Note:
request is of type ? extends RequestContext
entity is of type ? extends EntityProxy

(request).persist().using(entity).fire(
new Receiver<Void>() {
  @Override
  public void onSuccess(Void unUsed) {
    I need the entity ID generated in the DB here.
    If I do entity.getId(); it returns null obviously.
    As I don't know the ID here, I can't even refetch the persisted
entity.

You should be able to pass the entity.stableId() to RequestContext#find().
 
    The Receiver should have received the updated entity as arg to its
onSuccess.

As Patrick said, make your persist() method return the entity, if that's what you want. Or you can make it return the entity ID if you prefer (smaller payload, but you have to make an additional request if you want to retrieve it; apply the 80/20 rule to choose between a smaller response payload or less requests).
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/xTzuj4Rs0MoJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate