On Fri, Sep 23, 2011 at 8:40 PM, Magno Machado <[email protected]> wrote:
> And when the user press "save", I would call a method on the service to
> persist the whole entity in a single step, that is: There will be only one
> service method call
> Is this the right way of working with requestfactory?
Yes. The server side component of RequestFactory will create a 'Foo',
a List of 'Bar's, and call all the setters, including
setItems(listOfBars) on the Foo *before* the save/persist service
method is called, so in your save method you can take care of
persisting your 'items' collection.
> I had trouble with adding elements to the one-to-many relationship... My
> code was like this:
> BarProxy bar = request.create(BarProxy.class);
> bar.setXxx(...);
> foo.getItems().add(bar);
> But getItems() returns null, so it failed.
When creating a proxy on the client side, all fields will be null
initially, so you need to initialize it with an empty/already
populated list.
Its also important to use .with('items') when retrieving or sending an
object graph(ie, calling a service method), as relationships are not
sent over the wire unless you explicitly ask.
Aidan.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.