Thursday, September 29, 2011

[RequestFactory] Updating a proxy

Hi all,

Let's say I have a ThingProxy which has a GizmoProxy (and other stuff):

interface ThingProxy {
GizmoProxy getGizmo();
void setGizmo(GizmoProxy gizmo);
... other getters and setters ...

I need an instance of ThingProxy everywhere so I keep one available.
At some point I need to update something in its GizmoProxy. And that's
when the fun starts...

I see two approaches and neither works. :-(

First approach:
ThingProxy thing = ...;
ThingRequest thingRequest = RequestBuilder.newThingRequest();
ThingProxy mutableThing = thingRequest.edit(thing);
GizmoProxy mutableGizmo = mutableThing.getGizmo();
thingRequest.persist(mutableThing).fire(... receiver ...);

Unfortunately, this doesn't save the changes in the GizmoProxy.
Apparently, RF sees that the ThingProxy hasn't changed so it does
nothing (at least, nothing with the GizmoProxy).

Second approach:
ThingProxy thing = ...;
GizmoRequest gizmoRequest = RequestBuilder.newGizmoRequest();
GizmoProxy mutableGizmo = gizmoRequest.edit(thing.getGizmo());
gizmoRequest.persist(mutableGizmo).fire(... receiver ...);

This works fine and saves the change in GizmoProxy. But now ThingProxy
is out of date and I can't call setGizmo because the ThingProxy is
frozen. I tried using a mutable ThingProxy but then I get errors later
on (object is being edited in a different context).

How am I supposed to do this?


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment