Custom JavaScript

Vaadin is really JavaScript friendly. You can call JavaScript from the server, create JavaScript components and JavaScript extensions not to mention GWT capabilities such as JavaScript native interface and JavaScript overlay types.

Note

For more information on GWT JavaScript integration, visit https://developers.google.com/web-toolkit.

Calling JavaScript from the server

Calling JavaScript from the server is as easy as this:

JavaScript.getCurrent().execute("alert('Hello from server side.')");

That's it.

Calling the server from JavaScript

We can call our server from the client side using JavaScript. We need to add a JavaScript function as shown in the following code snippet:

JavaScript.getCurrent().addFunction("myFunction", new JavaScriptFunction() ...

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.