Wednesday, January 25, 2012

Re: RequestFactory: Download entity, add to collection, persist on server, see collection change. Should this work?



On Tuesday, January 24, 2012 10:02:24 PM UTC+1, Ryan McFall wrote:
I have an entity class Header, which contains a list of Response
objects.  Via a RequestFactory service I create a Header object and
send it back to the client, ensuring that the list of Response objects
is initialized before sending it to the client.

Then, on the client, I use the create method to create several
Response objects and add them to the Header proxy on the client side.
I then send another request to call a method (saveResponses) which
persists the Header object on the server, including a call to .with
("responses"), and then fire the request.

.with() only applies to things sent by the server; so you'd rather use .with("responses") in your first request that retrieve the HeaderProxy, and not the second request that saves it (unless if also returns the HeaderProxy and you want that object to have its responses property populated by the persisted ResponseProxy objects)

However, on the server side, the response objects are contained in the
list of responses for the Header object in the saveResponses method.

Should I expect this to work?  If so, are there any constraints on the
context in which it will work?  If not, why not - it seems like this
is basic functionality that should exist.  I have gotten around it by
writing methods to explicitly save the Response objects before saving
the Header object, but I don't think I should have to do this.

Not sure I understand your issue actually, but RF won't persist your Response objects for you, you have to either persist them individually, or persist them when you persist the Header object.
See http://code.google.com/p/google-web-toolkit/issues/detail?id=5389, http://code.google.com/p/google-web-toolkit/issues/detail?id=5724 and http://code.google.com/p/google-web-toolkit/issues/detail?id=5776 
(see "chained persistence" in http://tbroyer.posterous.com/gwt-211-requestfactory-part-ii, this article is a little old, but still mostly relevant)

--
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/-/hpLuqu-eQpwJ.
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.

No comments:

Post a Comment