thanks, I've got the patch already On Sat, Oct 9, 2010 at 11:42 AM, Patrick Julien <[email protected]> wrote: > thank you > > > On Sat, Oct 9, 2010 at 11:28 AM, <[email protected]> wrote: >> Reviewers: rjrjr, >> >> Description: >> Ensure that EntityProxy instances returned from Collections returned >> from an editable EntityProxy are editable. >> Patch by: bobv >> Review by: rjrjr >> Found by: pjulien >> >> >> Please review this at http://gwt-code-reviews.appspot.com/976801/show >> >> Affected files: >> M >> user/src/com/google/gwt/requestfactory/client/impl/EntityProxyCategory.java >> M user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java >> >> >> Index: >> user/src/com/google/gwt/requestfactory/client/impl/EntityProxyCategory.java >> =================================================================== >> --- >> user/src/com/google/gwt/requestfactory/client/impl/EntityProxyCategory.java >> (revision 8983) >> +++ >> user/src/com/google/gwt/requestfactory/client/impl/EntityProxyCategory.java >> (working copy) >> @@ -49,8 +49,7 @@ >> return stableId(bean).hashCode(); >> } >> >> - public static AbstractRequestContext requestContext( >> - AutoBean<? extends EntityProxy> bean) { >> + public static AbstractRequestContext requestContext(AutoBean<?> bean) { >> return (AbstractRequestContext) bean.getTag(REQUEST_CONTEXT); >> } >> >> @@ -70,13 +69,11 @@ >> * EntityProxy, that its return values are mutable. >> */ >> // CHECKSTYLE_OFF >> - public static <T> T __intercept(AutoBean<? extends EntityProxy> bean, >> - T returnValue) { >> + public static <T> T __intercept(AutoBean<?> bean, T returnValue) { >> // CHECKSTYLE_ON >> - if (!(returnValue instanceof EntityProxy)) { >> - return returnValue; >> - } >> + >> AbstractRequestContext context = requestContext(bean); >> + >> /* >> * The context will be null if the bean is immutable. If the context is >> * locked, don't try to edit. >> @@ -85,8 +82,26 @@ >> return returnValue; >> } >> >> - �...@suppresswarnings("unchecked") >> - T toReturn = (T) context.edit((EntityProxy) returnValue); >> - return toReturn; >> + /* >> + * EntityProxies need to be recorded specially by the RequestContext, >> so >> + * delegate to the edit() method for wiring up the context. >> + */ >> + if (returnValue instanceof EntityProxy) { >> + �...@suppresswarnings("unchecked") >> + T toReturn = (T) context.edit((EntityProxy) returnValue); >> + return toReturn; >> + } >> + >> + /* >> + * We're returning some object that's not an EntityProxy, most likely a >> + * Collection type. At the very least, propagate the current >> RequestContext >> + * so that editable chains can be constructed. >> + */ >> + AutoBean<T> otherBean = AutoBeanUtils.getAutoBean(returnValue); >> + if (otherBean != null) { >> + otherBean.setTag(EntityProxyCategory.REQUEST_CONTEXT, >> + bean.getTag(EntityProxyCategory.REQUEST_CONTEXT)); >> + } >> + return returnValue; >> } >> } >> Index: >> user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java >> =================================================================== >> --- user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java >> (revision 8983) >> +++ user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java >> (working copy) >> @@ -1762,6 +1762,10 @@ >> @Override >> public void onSuccess(SimpleFooProxy response) { >> assertEquals(2, response.getOneToManyField().size()); >> + >> + // Check lists of proxies returned from an mutable object are >> mutable >> + response = simpleFooRequest().edit(response); >> + response.getOneToManyField().get(0).setUserName("canMutate"); >> finishTestAndReset(); >> } >> }); >> >> >> -- >> http://groups.google.com/group/Google-Web-Toolkit-Contributors >
-- http://groups.google.com/group/Google-Web-Toolkit-Contributors
