RequestFactory: Child proxy is null on client side

56 views
Skip to first unread message

Julian

unread,
Sep 11, 2011, 11:34:57 AM9/11/11
to google-we...@googlegroups.com
Hi there

I'm having some difficulties using RequestFactory (and Objectify). I have two entities Item and Payload, and corresponding proxies ItemProxy and PayloadProxy (#1). If I call ItemRequestContext.saveAndReturn() on the clientside (#3) a simple println in my ItemDao shows the Payload as having an id (#2). But when the Response reaches the client side, the Payload is just null.

Is there some obvious reason why the Payload doesn't make it to the client side, given the code snippets below?


CODE SNIPPET #1

@Entity
public class Item extends DatastoreObjectGenerated {

   private Key<Payload> payloadKey;
   @Transient
   private Payload load;

   public Item() {
   }

   public void setPayload(Payload load) {
      this.load = load;
   }

   public Payload getPayload() {
      return this.load;
   }
}

@ProxyFor(value = Item.class, locator = ObjectifyGeneratedLocator.class)
public interface ItemProxy extends DatastoreObjectGeneratedProxy {

   public void setPayload(PayloadProxy load);

   public PayloadProxy getPayload();

}


@Entity
public class Payload extends DatastoreObject {

   public Payload() {
   }
}

@ProxyFor(value = Payload.class, locator = ObjectifyLocator.class)
public interface PayloadProxy extends DatastoreObjectProxy {

}



CODE SNIPPET #2

public class ItemDao extends ObjectifyDao<Item> {

   public Item saveAndReturn(Item item) {

      ...

      Item it = getItem(item.getId());
      System.out.println("Payload ID: " + it.getPayload().getId());

      return tr;
   }
}

// PRINTS
// Payload ID: 18

CODE SNIPPET #3

Request<ItemProxy> req = this.itemRequestContext.saveAndReturn(item);
req.fire(new Receiver<ItemProxy>() {
   @Override
   public void onSuccess(ItemProxy response) {
      System.out.println("Payload ID: " + response.getPayload());
   }
});

// PRINTS
// Payload ID: null

Aidan O'Kelly

unread,
Sep 11, 2011, 12:26:50 PM9/11/11
to google-we...@googlegroups.com
Think you need to add 'with("payload") to your RF request in the
client side code..

Request<ItemProxy> req = this.itemRequestContext.saveAndReturn(item);

to
Request<ItemProxy> req =
this.itemRequestContext.saveAndReturn(item).with("payload");

> --
> 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/-/THZWXQKKy0AJ.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

Julian

unread,
Sep 12, 2011, 1:59:41 PM9/12/11
to google-we...@googlegroups.com
Thank you Aidan!

.with("video") solved the problem :)

Somehow I thought it only applied to ValueProxies.

Reply all
Reply to author
Forward
0 new messages