TestRootProxy rootProxy =
requestContext.create(TestRootProxy.class); //Doesn't matter if it's a
loaded one or an unpersisted root
rootProxy.setChild(requestContext.create(TestChildProxy.class));
DefaultProxyStore store = new DefaultProxyStore();
ProxySerializer serializer = requestFactory.getSerializer(store);
String id = serializer.serialize(rootProxy);
String data = store.encode();
PersonProxy item =
DesktopEntryPoint.REQUEST_FACTORY.getSerializer(store).deserialize(TestRootProxy.class,
id);
requestContext = requestFactory.testRootRequest();
this.logger.info("Root stableId: " +
EntityProxyCategory.stableId(AutoBeanUtils.getAutoBean(item))); //This
will print out the same stable id as below.
this.logger.info("Child stableId: " +
EntityProxyCategory.stableId(AutoBeanUtils.getAutoBean(item.getChild())));
item = requestContext.edit(item);
item.getChild(); //This will throw a classcastexception as child is
overwritten now to be pointing to the TestRootProxy.
On Dec 29, 10:45 am, Kevin Jordan <ke...@kjordan.net> wrote:
> 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