From 26507a9c986908c3671ced8f14f30a60c84549c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Maxime=20M=C3=A9riouma-Caron?= Date: Tue, 1 Dec 2015 20:21:32 -0500 Subject: [PATCH] Fix databinding --- .../google/gwt/query/client/builders/JsonBuilderBase.java | 6 ++++++ .../gwt/query/client/dbinding/DataBindingTestJre.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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()); } -- 2.39.5