In some of my editors, I'm implementing ValueAwareEditor<P> and using 
provided proxy value in setValue to obtain editor-specific data (most 
simple example would be to get suggestions for some sub-editors). Problem 
is that proxy instance that I was given in setValue is already edited in 
driver's RequestContext, so I'm unable to use it as parameter in another 
context (for obtaining suggestions). Error is well known 
"IllegalArgumentException: Attempting to edit an EntityProxy previously 
edited by another RequestContext".

My current workaround is to first obtain fresh instance (via 
RequestContext.find(EntityProxyId<P>) and then use that (frozen) instance 
for performing my initial request (e.g. MyRequest.getSuggestions(P)). 
Drawback is that I have one unnecessary round-trip to the server.

Another solution wound be to refactor getSuggestions method to accept only 
id and rebuild full object on server side, but that seems to me as working 
around RequestFactory instead of using its provided services.

Least feasible solution is to propagate frozen proxy instance from top 
level editor all the way down editor hierarchy, but that leads to spaghetti 
code.

I know that RequestContext holds original (non-edit()ed, frozen) instance 
for every EntityProxy (for calculating diffs that it needs to send to 
server) - is there any way to get that original proxy from edited()-ed 
instance?

Any other suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to