Friday, September 30, 2011

Re: [RequestFactory] Updating a proxy

On 30 September 2011 00:54, Thomas Broyer <> wrote:
> Why would BasicUserService ( = GizmoService?) be called if you invoke
> UserRequest#persist(UserProxy) ( = ThingRequest#persist(ThingProxy) ?)

Because BasicUserProxy is part of UserProxy.

> It's hard to follow what you're expecting given that you switched from
> thing/gizmo/setSomething to [something-else]/user/basicUser/set[what?]

I wanted to keep it generic but see below.

> Could you post the actual code that led to the request whose payload you
> posted already?

Here you go:

final UserRequest userRequest =
final UserProxy mutableUser =
final BasicUserProxy mutableBasicUser = mutableUser.getBasicUser();
final int level = mutableBasicUser.getLevel();
final int basicCurrencyDelta = ...;
final int premiumCurrencyDelta = ...;
final int newLevel = level + 1;
final String comment = "Level Up to Level " + newLevel + ".";
final Receiver<Integer> levelUpReceiver = new LevelUpReceiver(...,
mutableUser, comment, basicCurrencyDelta, premiumCurrencyDelta);

LevelUpReceiver's onSuccess simply fires some events, including one
that sends out the by then presumably updated UserProxy (hence the
mutableUser in the constructor).

Given that BasicUserProxy is part of UserProxy, I would expect its
changes to be stored, i.e. I expect the entire object graph that is
UserProxy to be stored (as necessary).

Just to be complete:

@ProxyForName(value = "", locator =
public interface UserProxy extends EntityProxy
BasicUserProxy getBasicUser();
void setBasicUser(BasicUserProxy basicUser);
... a few others ...

@ProxyForName(value = "", locator =
public interface BasicUserProxy extends EntityProxy
int getLevel();
void setLevel(int level);
... a few others ...

In very short pseudo code, what I want to happen is the following:

User.BasicUser.Level := User.BasicUser.Level + 1;
Persist User (or BasicUser, I don't care);
Make sure that User.BasicUser.Level == BasicUser.Level, i.e. User's
BasicUser should be the newly updated one.

(I've tried persisting User but then BasicUser's changes are ignored;
persisting BasicUser works but then User references an outdated
BasicUser; I tried using the Editor framework but that didn't make any
difference either.)

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