diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-06-09 15:41:25 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2016-03-07 06:44:38 +0000 |
commit | 8f81ba9505520ba5fb44994710c08b69c273947a (patch) | |
tree | b484b89008c66de2fed61e103915f3ed4f681747 /client-compiler | |
parent | a00fd32041018899a4bb43268895525e67be32e9 (diff) | |
download | vaadin-framework-8f81ba9505520ba5fb44994710c08b69c273947a.tar.gz vaadin-framework-8f81ba9505520ba5fb44994710c08b69c273947a.zip |
Support string data in javascript renderers (#18209)
Change-Id: I2be48aa7a60920193a2f4bd9a413979cb9c48f34
Diffstat (limited to 'client-compiler')
-rw-r--r-- | client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java index 2e54d00aab..8b645aa492 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java @@ -22,8 +22,11 @@ import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JParameterizedType; import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.vaadin.client.connectors.AbstractRendererConnector; +import elemental.json.JsonValue; + /** * Generates type data for renderer connectors. * <ul> @@ -86,12 +89,33 @@ public class RendererVisitor extends TypeVisitor { JType presentationType = getPresentationType(type, logger); bundle.setPresentationType(type, presentationType); - bundle.setNeedsSerialize(presentationType); + if (!hasCustomDecodeMethod(type, logger)) { + bundle.setNeedsSerialize(presentationType); + } logger.log(Type.DEBUG, "Presentation type of " + type + " is " + presentationType); } + private static boolean hasCustomDecodeMethod(JClassType type, + TreeLogger logger) throws UnableToCompleteException { + try { + JMethod decodeMethod = ConnectorBundle.findInheritedMethod(type, + "decode", + type.getOracle().getType(JsonValue.class.getName())); + if (decodeMethod == null) { + throw new NotFoundException(); + } + + return !decodeMethod.getEnclosingType().getQualifiedSourceName() + .equals(AbstractRendererConnector.class.getName()); + } catch (NotFoundException e) { + logger.log(Type.ERROR, "Can't find decode method for renderer " + + type, e); + throw new UnableToCompleteException(); + } + } + private static JType getPresentationType(JClassType type, TreeLogger logger) throws UnableToCompleteException { JClassType originalType = type; |