From: Maxime Mériouma-Caron Date: Wed, 2 Dec 2015 01:21:32 +0000 (-0500) Subject: Fix databinding X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=26507a9c986908c3671ced8f14f30a60c84549c1;p=gwtquery.git Fix databinding --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java index 996f245c..113d6fd6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java @@ -26,6 +26,7 @@ import com.google.gwt.query.client.js.JsObjectArray; import com.google.gwt.query.client.js.JsUtils; import java.util.Arrays; +import java.util.Collection; import java.util.List; /** @@ -166,6 +167,11 @@ public abstract class JsonBuilderBase> implements J public T set(Object key, Object val) { if (val instanceof IsProperties) { p.set(key, ((IsProperties) val).getDataImpl()); + } else if (val instanceof Object[]) { + setArrayBase(String.valueOf(key), (Object[]) val); + } else if (val instanceof Collection) { + Collection collection = (Collection) val; + setArrayBase(String.valueOf(key), collection.toArray(new Object[collection.size()])); } else { p.set(key, val); } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index 3652ab43..903ef138 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -230,11 +230,11 @@ public class DataBindingTestJre extends GWTTestCase { user.set("name", "Random Name"); user.set("phones", Collections.emptyList()); String json = user.toJson(); - + //WHEN fetching that user GUser retrievedUser = GQ.create(GUser.class); retrievedUser.parse(json, true); - + //THEN assertEquals(0, retrievedUser.getPhones().size()); }