aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-01-10 12:56:52 +0200
committerVaadin Code Review <review@vaadin.com>2015-01-12 08:46:08 +0000
commit35d91245de3218283c8f4c733a3aa72ea395fb1c (patch)
tree7b4fb520d6a733403ed9a335d0442a64cf646be6 /client/src
parent28dbd0c0dad3491d1f4d405e753075df983ecacc (diff)
downloadvaadin-framework-35d91245de3218283c8f4c733a3aa72ea395fb1c.tar.gz
vaadin-framework-35d91245de3218283c8f4c733a3aa72ea395fb1c.zip
Support JsonValue types as declared types in state and RPC (#15560)
Change-Id: I2779a533811bb1b60c4e74789f6378574bc6ac61
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/communication/JsonDecoder.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/communication/JsonDecoder.java b/client/src/com/vaadin/client/communication/JsonDecoder.java
index a8adbac0c6..0ce89c873e 100644
--- a/client/src/com/vaadin/client/communication/JsonDecoder.java
+++ b/client/src/com/vaadin/client/communication/JsonDecoder.java
@@ -82,13 +82,16 @@ public class JsonDecoder {
*/
public static Object decodeValue(Type type, JsonValue jsonValue,
Object target, ApplicationConnection connection) {
+ String baseTypeName = type.getBaseTypeName();
+ if (baseTypeName.startsWith("elemental.json.Json")) {
+ return jsonValue;
+ }
- // Null is null, regardless of type
+ // Null is null, regardless of type (except JSON)
if (jsonValue.getType() == JsonType.NULL) {
return null;
}
- String baseTypeName = type.getBaseTypeName();
if (Map.class.getName().equals(baseTypeName)
|| HashMap.class.getName().equals(baseTypeName)) {
return decodeMap(type, jsonValue, connection);
@@ -293,4 +296,14 @@ public class JsonDecoder {
tokens.add(decodeValue(childType, entryValue, null, connection));
}
}
+
+ /**
+ * Called by generated deserialization code to treat a generic object as a
+ * JsonValue. This is needed because GWT refuses to directly cast String
+ * typed as Object into a JSO.
+ */
+ public static native <T extends JsonValue> T obj2jso(Object object)
+ /*-{
+ return object;
+ }-*/;
}