Ok, so now I did this:
on view start:
bars = new ArrayList<BarProxy>();
foo = request.create(FooProxy.class);
foo.setBars(bars);

when adding one item:
bar = request.create(BarProxy.class);
bar.setXxx(...);
bars.add(bar);

when saving:
request.persist(foo);
request.fire();

But only foo got persisted, not it's bars

On Fri, Sep 23, 2011 at 6:25 PM, Aidan O'Kelly <[email protected]> wrote:

> 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.
>
>


-- 
Magno Machado Paulo
http://blog.magnomachado.com.br
http://code.google.com/p/emballo/

-- 
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.

Reply via email to