summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-06-09 15:41:25 +0300
committerLeif Åstrand <leif@vaadin.com>2016-03-07 06:44:38 +0000
commit8f81ba9505520ba5fb44994710c08b69c273947a (patch)
treeb484b89008c66de2fed61e103915f3ed4f681747 /client
parenta00fd32041018899a4bb43268895525e67be32e9 (diff)
downloadvaadin-framework-8f81ba9505520ba5fb44994710c08b69c273947a.tar.gz
vaadin-framework-8f81ba9505520ba5fb44994710c08b69c273947a.zip
Support string data in javascript renderers (#18209)
Change-Id: I2be48aa7a60920193a2f4bd9a413979cb9c48f34
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java b/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java
index 112623d1fe..1229922a9c 100644
--- a/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java
+++ b/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java
@@ -42,9 +42,11 @@ import elemental.json.JsonValue;
* @since 7.4
* @author Vaadin Ltd
*/
+// This is really typed to <JsonValue>, but because of the way native strings
+// are not always instanceof JsonValue, we need to accept Object
@Connect(AbstractJavaScriptRenderer.class)
public class JavaScriptRendererConnector extends
- AbstractRendererConnector<JsonValue> implements
+ AbstractRendererConnector<Object> implements
HasJavaScriptConnectorHelper {
private final JavaScriptConnectorHelper helper = new JavaScriptConnectorHelper(
this);
@@ -131,7 +133,7 @@ public class JavaScriptRendererConnector extends
}-*/;
@Override
- protected Renderer<JsonValue> createRenderer() {
+ protected Renderer<Object> createRenderer() {
helper.ensureJavascriptInited();
if (!hasFunction("render")) {
@@ -146,11 +148,13 @@ public class JavaScriptRendererConnector extends
final boolean hasGetConsumedEvents = hasFunction("getConsumedEvents");
final boolean hasOnBrowserEvent = hasFunction("onBrowserEvent");
- return new ComplexRenderer<JsonValue>() {
+ return new ComplexRenderer<Object>() {
@Override
- public void render(RendererCellReference cell, JsonValue data) {
- render(helper.getConnectorWrapper(), getJsCell(cell),
- Util.json2jso(data));
+ public void render(RendererCellReference cell, Object data) {
+ if (data instanceof JsonValue) {
+ data = Util.json2jso((JsonValue) data);
+ }
+ render(helper.getConnectorWrapper(), getJsCell(cell), data);
}
private JavaScriptObject getJsCell(CellReference<?> cell) {
@@ -159,7 +163,7 @@ public class JavaScriptRendererConnector extends
}
public native void render(JavaScriptObject wrapper,
- JavaScriptObject cell, JavaScriptObject data)
+ JavaScriptObject cell, Object data)
/*-{
wrapper.render(cell, data);
}-*/;
@@ -262,7 +266,7 @@ public class JavaScriptRendererConnector extends
}
@Override
- public JsonValue decode(JsonValue value) {
+ public Object decode(JsonValue value) {
// Let the js logic decode the raw json that the server sent
return value;
}