Thursday, December 29, 2011

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

There's a line missing between the "String data = " and the incorrect
pasted line "PersonProxy item =".

For my example it should read:
store = new DefaultProxyStore(data); //Recreate store from serialized
data.
TestRootProxy item =
requestFactory.getSerializer(store).deserialize(TestRootProxy.class,
id); //Deserialize it to the original Proxy.

And in production this would be read either from client-side storage
or through a call to the server to get the serialized string instead
of in one flow. But it behaves the same either way.

On Dec 29, 11:16 am, Kevin Jordan <ke...@kjordan.net> wrote:
> Simple case in case my wording was a little confusing:
>
> 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(TestRoot Proxy.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.

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