diff options
author | Maxime Mériouma-Caron <maxime.meriouma@arcbees.com> | 2015-12-01 20:21:32 -0500 |
---|---|---|
committer | Maxime Mériouma-Caron <maxime.meriouma@arcbees.com> | 2015-12-01 20:21:32 -0500 |
commit | 26507a9c986908c3671ced8f14f30a60c84549c1 (patch) | |
tree | 6d8d757188fc6a43b4dc90a4f962a557ce1dc1c8 | |
parent | 3c40171b04ac1de5a3f477fc9a55cdba6058a085 (diff) | |
download | gwtquery-26507a9c986908c3671ced8f14f30a60c84549c1.tar.gz gwtquery-26507a9c986908c3671ced8f14f30a60c84549c1.zip |
Fix databinding
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java | 6 | ||||
-rw-r--r-- | gwtquery-core/src/test/java/com/google/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<J extends JsonBuilderBase<?>> implements J public <T extends IsProperties> 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()); } |