summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests
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 /uitest/src/com/vaadin/tests
parenta00fd32041018899a4bb43268895525e67be32e9 (diff)
downloadvaadin-framework-8f81ba9505520ba5fb44994710c08b69c273947a.tar.gz
vaadin-framework-8f81ba9505520ba5fb44994710c08b69c273947a.zip
Support string data in javascript renderers (#18209)
Change-Id: I2be48aa7a60920193a2f4bd9a413979cb9c48f34
Diffstat (limited to 'uitest/src/com/vaadin/tests')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.java29
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.js5
4 files changed, 42 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java
index 4bfa244c22..8f88883161 100644
--- a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java
+++ b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderers.java
@@ -55,6 +55,7 @@ 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);
@@ -62,6 +63,7 @@ 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);
@@ -69,6 +71,8 @@ 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 2e86053ef3..917245188a 100644
--- a/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java
@@ -34,9 +34,13 @@ 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
new file mode 100644
index 0000000000..ab3be6f4f1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.java
@@ -0,0 +1,29 @@
+/*
+ * 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
new file mode 100644
index 0000000000..475b453dcc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/JavaScriptStringRenderer.js
@@ -0,0 +1,5 @@
+com_vaadin_tests_components_grid_JavaScriptStringRenderer = function() {
+ this.render = function(cell, data) {
+ cell.element.textContent = data;
+ }
+} \ No newline at end of file