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.
On Fri, Sep 23, 2011 at 10:37 PM, Thomas Broyer <t.br...@gmail.com> wrote:
> Note that the. with() only applies to return values, not to arguments. I.e. from server to client only.
>
> --
> 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/-/MYVEkj1-a6QJ.
> 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.
>
>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
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.
> But only foo got persisted, not it's bars
RequestFactory itself doesn't persist anything, it just synchronizes
the object graph between client & server. How exactly you would
persist a Foo, a list of Bars, and the relationship is dependent on
what data storage you are using, so there needs to be logic inside the
persist() method of Foo, that persists not only the Foo, but any
relationships and their objects.
If you inspect Foo.getItems() inside the Foo's persist() method, a
list of Bars should be there, that's where RequestFactory's part ends.
> --
> 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/-/szisuiWUylIJ.
I'm having a very similar issue where my new bars are not being persisted on the server. When I examine the list from within its setter on the server, I can see that the new bar objects are in the list but the fields are all null, even though I set them explicitly on the client. Is there something that I'm missing here?
BTW, when I try to debug RF with the dumpPayload flag it shows the payload but in an unreadable format - is there a way to set it to become readable?