Revision: 9774
Author: [email protected]
Date: Mon Feb 28 04:38:20 2011
Log: Fix issue 6059, ClassCastException when using ValueProxy with isChanged().
http://gwt-code-reviews.appspot.com/1352810
Patch by: t.broyer
Review by: bobv

http://code.google.com/p/google-web-toolkit/source/detail?r=9774

Modified:
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/AbstractRequestContext.java /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java

=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/shared/impl/AbstractRequestContext.java Thu Feb 24 12:41:17 2011 +++ /trunk/user/src/com/google/gwt/requestfactory/shared/impl/AbstractRequestContext.java Mon Feb 28 04:38:20 2011
@@ -151,8 +151,8 @@
       if (!raw.isNull("error")) {
         Splittable error = raw.get("error");
         ServerFailure failure = new ServerFailure(
-          error.get("message").asString(),
-          error.get("code").asString(), payload, true);
+            error.get("message").asString(), error.get("code").asString(),
+            payload, true);
         fail(receiver, failure);
         return;
       }
@@ -505,11 +505,11 @@
* simple flag-check because of the possibility of "unmaking" a change, per
      * the JavaDoc.
      */
-    for (AutoBean<?> bean : editedProxies.values()) {
+    for (AutoBean<? extends BaseProxy> bean : editedProxies.values()) {
       AutoBean<?> previous = bean.getTag(Constants.PARENT_OBJECT);
       if (previous == null) {
         // Compare to empty object
- Class<?> proxyClass = ((EntityProxy) bean.as()).stableId().getProxyClass();
+        Class<?> proxyClass = stableId(bean).getProxyClass();
previous = getRequestFactory().getAutoBeanFactory().create(proxyClass);
       }
       if (!AutoBeanUtils.diff(previous, bean).isEmpty()) {
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Thu Dec 23 11:25:33 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Mon Feb 28 04:38:20 2011
@@ -270,6 +270,22 @@
     foo.setCharField(null);
     assertFalse(context.isChanged());
   }
+
+  public void testChangedCreateValueProxy() {
+    SimpleFooRequest context = simpleFooRequest();
+
+    // Creates don't cause a change
+    SimpleValueProxy foo = context.create(SimpleValueProxy.class);
+    assertFalse(context.isChanged());
+
+    // Change
+    foo.setString("foo");
+    assertTrue(context.isChanged());
+
+    // Undo the change
+    foo.setString(null);
+    assertFalse(context.isChanged());
+  }

   public void testChangedEdit() {
     delayTestFinish(DELAY_TEST_FINISH);

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to