Thursday, December 29, 2011

Re: RequestFactory Value Proxy Use Case

The difference between ValueProxy and EntityProxy is that ValueProxy-s do not have "identity". Two EntityProxy-s can be said to represent the same object if they share the same stableId(); that cannot be said for ValueProxy, where each instance is a distinct object. For instance, when you RequestContext#edit() a ValueProxy, you create a clone. Another difference: ValueProxy-s are compared equals() by their properties' values. Obviously, while EntityProxy sends diffs of the modified properties from the client to the server, ValueProxy-s are always sent as a whole: there's nothing to diff against.

You can use a Locator with a ValueProxy, it's just that only the create() method will ever be called (so all other methods: find(), getId(), getVersion(), etc. should probably throw an UnsupportedOperationException). If your server-side class has a zero-arg constructor, then you don't need a Locator: being proxied by a ValueProxy, the requirements are different that from EntityProxy-s: no need for a static findXxx method, or getId or getVersion instance methods.

Apart from that, it works just like EntityProxy-s.

You can also see ValueProxy-s like the objects you'd transfer using GWT-RPC: when you send an object from client to server, or from server to client, you're making a "copy", created from scratch (with EntityProxy on the other hand, the "base object" could be retrieved from your database before being modified; with ValueProxy, a new instance is created each time).
If you're moving from GWT-RPC, I'd start using ValueProxy so your methods calls have the same semantics as with GWT-RPC, then move to EntityProxy if you want/need it.

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