diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2016-04-15 08:03:57 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-04-15 08:04:05 +0000 |
commit | 099faa9944b8aadc9cc57db388e856885cbecc85 (patch) | |
tree | cfcf5c3525f18cf158a03a4efb1b4d49ab0ce6f7 | |
parent | ae59ed7666c67abd9ad036fece6854c3032e7529 (diff) | |
download | vaadin-framework-099faa9944b8aadc9cc57db388e856885cbecc85.tar.gz vaadin-framework-099faa9944b8aadc9cc57db388e856885cbecc85.zip |
Revert "Support string data in javascript renderers (#18209)"
This reverts commit ff66c79a045a15f4d1b4fd6f962b2139be21affb.
Change-Id: I14f4a4c0b78379e4b22830c1450ef16de229696c
6 files changed, 9 insertions, 79 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 8b645aa492..2e54d00aab 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java @@ -22,11 +22,8 @@ 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> @@ -89,33 +86,12 @@ public class RendererVisitor extends TypeVisitor { JType presentationType = getPresentationType(type, logger); bundle.setPresentationType(type, presentationType); - if (!hasCustomDecodeMethod(type, logger)) { - bundle.setNeedsSerialize(presentationType); - } + 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; diff --git a/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java b/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java index 1229922a9c..112623d1fe 100644 --- a/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/JavaScriptRendererConnector.java @@ -42,11 +42,9 @@ 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<Object> implements + AbstractRendererConnector<JsonValue> implements HasJavaScriptConnectorHelper { private final JavaScriptConnectorHelper helper = new JavaScriptConnectorHelper( this); @@ -133,7 +131,7 @@ public class JavaScriptRendererConnector extends }-*/; @Override - protected Renderer<Object> createRenderer() { + protected Renderer<JsonValue> createRenderer() { helper.ensureJavascriptInited(); if (!hasFunction("render")) { @@ -148,13 +146,11 @@ public class JavaScriptRendererConnector extends final boolean hasGetConsumedEvents = hasFunction("getConsumedEvents"); final boolean hasOnBrowserEvent = hasFunction("onBrowserEvent"); - return new ComplexRenderer<Object>() { + return new ComplexRenderer<JsonValue>() { @Override - public void render(RendererCellReference cell, Object data) { - if (data instanceof JsonValue) { - data = Util.json2jso((JsonValue) data); - } - render(helper.getConnectorWrapper(), getJsCell(cell), data); + public void render(RendererCellReference cell, JsonValue data) { + render(helper.getConnectorWrapper(), getJsCell(cell), + Util.json2jso(data)); } private JavaScriptObject getJsCell(CellReference<?> cell) { @@ -163,7 +159,7 @@ public class JavaScriptRendererConnector extends } public native void render(JavaScriptObject wrapper, - JavaScriptObject cell, Object data) + JavaScriptObject cell, JavaScriptObject data) /*-{ wrapper.render(cell, data); }-*/; @@ -266,7 +262,7 @@ public class JavaScriptRendererConnector extends } @Override - public Object decode(JsonValue value) { + public JsonValue decode(JsonValue value) { // Let the js logic decode the raw json that the server sent return value; } diff --git a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java index 8f88883161..4bfa244c22 100644 --- a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java +++ b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java @@ -55,7 +55,6 @@ public class JavaScriptRenderers extends AbstractTestUI { IndexedContainer container = new IndexedContainer(); container.addContainerProperty("id", Integer.class, Integer.valueOf(0)); container.addContainerProperty("bean", MyBean.class, null); - container.addContainerProperty("string", String.class, ""); for (int i = 0; i < 1000; i++) { Integer itemId = Integer.valueOf(i); @@ -63,7 +62,6 @@ public class JavaScriptRenderers extends AbstractTestUI { item.getItemProperty("id").setValue(itemId); item.getItemProperty("bean").setValue( new MyBean(i + 1, Integer.toString(i - 1))); - item.getItemProperty("string").setValue("string" + i); } Grid grid = new Grid(container); @@ -71,8 +69,6 @@ public class JavaScriptRenderers extends AbstractTestUI { grid.getColumn("bean").setRenderer(new MyBeanJSRenderer()); grid.getColumn("bean").setWidth(250); - grid.getColumn("string").setRenderer(new JavaScriptStringRenderer()); - addComponent(grid); } diff --git a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java index 917245188a..2e86053ef3 100644 --- a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java @@ -34,13 +34,9 @@ public class JavaScriptRenderersTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); GridCellElement cell_1_1 = grid.getCell(1, 1); - GridCellElement cell_2_2 = grid.getCell(2, 2); - // Verify render functionality Assert.assertEquals("Bean(2, 0)", cell_1_1.getText()); - Assert.assertEquals("string2", cell_2_2.getText()); - // Verify init functionality Assert.assertEquals("1", cell_1_1.getAttribute("column")); diff --git a/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.java b/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.java deleted file mode 100644 index ab3be6f4f1..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.grid; - -import com.vaadin.annotations.JavaScript; -import com.vaadin.ui.renderers.AbstractJavaScriptRenderer; - -@JavaScript("JavaScriptStringRenderer.js") -public class JavaScriptStringRenderer extends - AbstractJavaScriptRenderer<String> { - - protected JavaScriptStringRenderer() { - super(String.class); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.js b/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.js deleted file mode 100644 index 475b453dcc..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.js +++ /dev/null @@ -1,5 +0,0 @@ -com_vaadin_tests_components_grid_JavaScriptStringRenderer = function() { - this.render = function(cell, data) { - cell.element.textContent = data; - } -}
\ No newline at end of file |