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();
mutableGizmo.setSomething(...);
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());
mutableGizmo.setSomething(...);
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?

Cheers,
Hilco

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
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