From 24e3409e6ff117ff954f36a9c9378690c76634f8 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Sun, 10 Jun 2012 15:10:10 +0300 Subject: Initial support for javascript components (#8888) --- WebContent/statictestfiles/jsconnector.js | 12 ++++++++++++ WebContent/statictestfiles/jsextension.js | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 WebContent/statictestfiles/jsconnector.js create mode 100644 WebContent/statictestfiles/jsextension.js (limited to 'WebContent') diff --git a/WebContent/statictestfiles/jsconnector.js b/WebContent/statictestfiles/jsconnector.js new file mode 100644 index 0000000000..db8a065e86 --- /dev/null +++ b/WebContent/statictestfiles/jsconnector.js @@ -0,0 +1,12 @@ +window.com_vaadin_tests_components_javascriptcomponent_BasicJavascriptComponent_ExampleWidget = function() { + var connector = this; + + var rootElement = connector.getWidgetElement(); + rootElement.innerHTML = 'Hello world!'; + rootElement.onclick = function() { + connector.getRpcProxyFunction("com.vaadin.tests.components.javascriptcomponent.BasicJavascriptComponent$ExampleClickRpc", "onClick")("message"); + } + connector.onStateChange = function() { + console.log('state change:', this.getState()); + } +} \ No newline at end of file diff --git a/WebContent/statictestfiles/jsextension.js b/WebContent/statictestfiles/jsextension.js new file mode 100644 index 0000000000..df67db8927 --- /dev/null +++ b/WebContent/statictestfiles/jsextension.js @@ -0,0 +1,13 @@ +window.com_vaadin_tests_features_SimpleJavascriptExtensionTest_SimpleJavascriptExtension = function() { + var state = this.getState(); + var greetBack = this.getRpcProxyFunction('com.vaadin.tests.features.SimpleJavascriptExtensionTest$SimpleJavascriptExtensionServerRpc', 'greet'); + + this.registerRpc("com.vaadin.tests.features.SimpleJavascriptExtensionTest.SimpleJavascriptExtensionClientRpc", { + 'greet': function(greeting) { + var response = window.prompt(state.prefix + greeting); + if (response !== null) { + greetBack(response); + } + } + }); +} \ No newline at end of file -- cgit v1.2.3