Requestfactory : best practice for persisting updates with Locator
63 views
Skip to first unread message
Dominik Steiner
unread,
Aug 31, 2011, 8:46:18 AM8/31/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
Hi,
I finally did a first try at RF and am wondering what is the best way
to implement the persist method on a Locator class in order to deal
with only the deltas send from the client?
As right now my persist(T objectToPersist) method on the Locator is
doing a create if the object has no id associated to it. This use case
is pretty similar to what i would have done with RPC as the whole
object is being sent evidently. But when i then reload the object from
the server, change some properties on it and call persist again a
pretty 'light' objectToPersist appears in that method which seems to
even have lost the PK on the associations in that object.
So am i missing something or is there a good way to implement those
updates especially when dealing with associations in that object?
Thanks
Dominik Steiner
unread,
Sep 1, 2011, 12:36:41 PM9/1/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
Perhaps a small test case might better explain what problem i'm facing
with the delta's send from request factory to the locator class (the
fire() method is in order to do synchronous testing of the requests
sent)
So on the server the service method just looks like this
public IntegerResponse persist(Foo foo)
and the
public class Foo{
Integer id;
String name;
List<Bar> bars;
|
and Bar might have a composite id
public class Bar {
BarPK barPK;
}
public class BarPK{
Integer fooId;
String name;
}
When it is created all properties gets sent to the persist() method
and the full object can easily be persisted using hibernate. The
second time an update is occuring on that object the fooId will be
null as no changes have been made to that on the client evidently.
This makes working with the Foo foo object in the persist method quite
manual. And how would i differentiate if some null property is just
not sent because no update has occured or because it has been reset to
null? Is such a use case not supported by RF and i have to stick with
RPC?