Order of sub-editor setters in RequestFactoryEditorDriver

38 views
Skip to first unread message

Robert Quinn

unread,
Aug 25, 2011, 11:01:44 AM8/25/11
to Google Web Toolkit
I am creating a RequestFactory context by calling edit() on a proxy
(which contains sub-proxies).

I have an editor for the proxy (with sub-editors for the sub-proxies).

Call this proxy the "top-level proxy"

The editor framework automatically calls context.edit() on any sub-
proxies it encounters (which is helpful); however, this means when the
driver is flushed, the setters for the top-level proxy are called
first, followed by its children's setters, and so on. So when I use
the default editor framework behavior, my top-level proxy proxy will
never accurately reflect the editor changes.

Do I really have to manually call edit on all my sub-proxies in a leaf-
first way in order to get the behavior I need? Shouldn't the driver
do it that way be default?

Or am I thinking of this incorrectly?

Robert Quinn

unread,
Aug 26, 2011, 12:26:33 AM8/26/11
to Google Web Toolkit
Can I generalize here and say: "Any time I want to persist edits to
proxy and its sub-proxies using a single editor (with embedded sub-
editors), then I always have to explicitly call edit() on all the sub-
proxies before calling it on the proxy?"

Thomas Broyer

unread,
Aug 26, 2011, 8:49:21 AM8/26/11
to google-we...@googlegroups.com
If your code depends on call orders, then you'll have issues even without the Editor framework: as soon as you call a getter to retrieve a related proxy out of an edit()ed proxy, that other proxy will automatically be edit()ed too, so that you can write code like:
MyProxy myProxy = ctxt.edit(someProxy);
myProxy.getSubProxy().setFoo("foo");
without the need to edit(myProxy.getSubProxy()) and store it in another variable.

IMO, you'd rather change your assumptions on the server-side to no longer depend on setter's call order.

(FYI, the Editor calls edit() on each subproxy because it "walks" down the proxy passed as argument, which may or may not be edit()ed itself; and each ValueAwareEditor or LeafValueEditor is passed the "non-edit()ed" proxy, the edit()ed one being used only on flush())
Reply all
Reply to author
Forward
0 new messages