From 2b0cb55ef291f8f8a95e45c4afa87ca3b2e650b8 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 9 Aug 2012 16:36:39 +0300 Subject: Add an API for modifying the bootstrap page. (#9274) --- ...aadin.terminal.gwt.server.VaadinContextListener | 1 + .../vaadin/tests/vaadincontext/BoostrapModify.html | 31 ++++++++++++++++++++ .../tests/vaadincontext/BoostrapModifyRoot.java | 28 ++++++++++++++++++ .../vaadincontext/TestVaadinContextListener.java | 33 ++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java (limited to 'tests/testbench') diff --git a/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener b/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener new file mode 100644 index 0000000000..fd5ebaa53e --- /dev/null +++ b/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener @@ -0,0 +1 @@ +com.vaadin.tests.vaadincontext.TestVaadinContextListener \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html new file mode 100644 index 0000000000..d5ab5af108 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html @@ -0,0 +1,31 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.vaadincontext.BoostrapModifyRoot?restartApplication
assertTextvaadin=runcomvaadintestsvaadincontextBoostrapModifyRoot::/VVerticalLayout[0]/VLabel[0]There should be a static h1 in the HTML of the bootstrap page for this Root
assertText//h1This is a heading
+ + diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java new file mode 100644 index 0000000000..3af096ff37 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java @@ -0,0 +1,28 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.tests.vaadincontext; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; + +public class BoostrapModifyRoot extends AbstractTestRoot { + + @Override + protected void setup(WrappedRequest request) { + // TODO Auto-generated method stub + + } + + @Override + protected String getTestDescription() { + return "There should be a static h1 in the HTML of the bootstrap page for this Root"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9274); + } + +} diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java new file mode 100644 index 0000000000..fa2767a023 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java @@ -0,0 +1,33 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.tests.vaadincontext; + +import com.vaadin.terminal.gwt.server.BootstrapListener; +import com.vaadin.terminal.gwt.server.BootstrapResponse; +import com.vaadin.terminal.gwt.server.VaadinContextEvent; +import com.vaadin.terminal.gwt.server.VaadinContextListener; +import com.vaadin.ui.Root; + +public class TestVaadinContextListener implements VaadinContextListener { + @Override + public void contextCreated(VaadinContextEvent event) { + event.getVaadinContext().addBootstrapListener(new BootstrapListener() { + @Override + public void modifyBootstrap(BootstrapResponse response) { + Root root = response.getRoot(); + if (root != null && root.getClass() == BoostrapModifyRoot.class) { + response.getApplicationTag().before( + "

This is a heading

"); + } + } + }); + } + + @Override + public void contextDestoryed(VaadinContextEvent event) { + // Nothing to do + } + +} -- cgit v1.2.3 From 454f44738b20b22aeeb327523f1306b46d3cbef6 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 10 Aug 2012 10:40:53 +0300 Subject: Revert "Run JavaScript RPC with this pointing to the connector wrapper (#9096)" This reverts commit ab2846641bff895b9e82bfd8068c720e8132e297. This fixes #9280 --- .../vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java | 9 ++++----- .../vaadin/tests/minitutorials/v7a3/complex_types_connector.js | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/testbench') diff --git a/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java b/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java index 69b8e00603..47dd2df5b2 100644 --- a/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java +++ b/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java @@ -331,9 +331,9 @@ public class JavaScriptConnectorHelper { invokeCallback(getConnectorWrapper(), callbackName, arguments); } else { JavaScriptObject arguments = parametersJson.getJavaScriptObject(); - invokeJsRpc(rpcMap, iface, method, arguments, getConnectorWrapper()); + invokeJsRpc(rpcMap, iface, method, arguments); // Also invoke wildcard interface - invokeJsRpc(rpcMap, "", method, arguments, getConnectorWrapper()); + invokeJsRpc(rpcMap, "", method, arguments); } } @@ -344,8 +344,7 @@ public class JavaScriptConnectorHelper { }-*/; private static native void invokeJsRpc(JavaScriptObject rpcMap, - String interfaceName, String methodName, - JavaScriptObject parameters, JavaScriptObject connector) + String interfaceName, String methodName, JavaScriptObject parameters) /*-{ var targets = rpcMap[interfaceName]; if (!targets) { @@ -353,7 +352,7 @@ public class JavaScriptConnectorHelper { } for(var i = 0; i < targets.length; i++) { var target = targets[i]; - target[methodName].apply(connector, parameters); + target[methodName].apply(target, parameters); } }-*/; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/complex_types_connector.js b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/complex_types_connector.js index 85dfb1369b..496afce432 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/complex_types_connector.js +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/complex_types_connector.js @@ -1,8 +1,9 @@ window.com_vaadin_tests_minitutorials_v7a3_ComplexTypesComponent = function() { + var connectorId = this.getConnectorId(); + var element = this.getElement(); + this.registerRpc({ sendComplexTypes: function(list, stringMap, otherMap, connectorMap, bits, matrix, bean) { - var connectorId = this.getConnectorId(); - var message = 'list[2] = "' + list[2] + '"
'; message += 'stringMap.two = ' + stringMap.two + '
'; message += 'otherMap[1][1] = "' + otherMap[1][1] + '"
'; @@ -11,7 +12,7 @@ window.com_vaadin_tests_minitutorials_v7a3_ComplexTypesComponent = function() { message += 'matrix[0][1] = ' + matrix[0][1] + '
'; message += 'bean.bean.integer = ' + bean.bean.integer + '
'; - this.getElement().innerHTML = message; + element.innerHTML = message; } }); } \ No newline at end of file -- cgit v1.2.3