Thursday, December 29, 2011

Serializing and Deserializing EntityProxy with created EntityProxy inside makes root EntityProxy have created EntityProxy's stableId

I'm trying to preserve a modified EntityProxy's state between user
session by using the ProxyStore to serialize it and deserialize it,
but it appears that if it has a reference EntityProxy in a field
inside, the root proxy's stableId gets overriden with the one of the
created EntityProxy. This leads to it getting replaced incorrectly on
a .edit() of it such that everything gets set to the root proxy when
it goes to clone it. I believe the problem lies with how it does the
operations here:

@Override
<Q extends BaseProxy> AutoBean<Q>
getProxyForReturnPayloadGraph(SimpleProxyId<Q> id) {
AutoBean<Q> toReturn = super.getProxyForReturnPayloadGraph(id);
if (restored.add(id)) {
/*
* If we haven't seen the id before, use the data in the
OperationMessage
* to repopulate the properties of the canonical bean for this
id.
*/
OperationMessage op =
getOperation(getRequestFactory().getHistoryToken(id));
this.processReturnOperation(id, op);
toReturn.setTag(Constants.STABLE_ID, super.getId(op));
}
return toReturn;
}

Although I'm not exactly sure why it gets the wrong id set. They also
seem to have perfectly good stable ids set before it gets to the
setTag function too, so I'm not sure why it's necessary to do that.

I'd also tried doing it manually via AutoBeanCodex, but it seems I'd
have to force a lot of stuff including stable ids and frozen statuses
into the proxies that way. Has anyone had any luck with serializing
and deserializing EntityProxies with un-persisted proxies inside the
root proxy?

--
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