How to send data back to the server side?

Hi
It’s code from docs:

 public static void logElementSize(String name, Element element) {
        Page page = UI.getCurrent().getPage();

        page.executeJavaScript(
                "console.log($0 + ' size:', $1.offsetWidth, $1.offsetHeight)", name, element);
    }

Note The script is executed asynchronously, so you can’t directly pass values back to the server.

How to send this results back to server side?

Have a look at the replies to my question [here]
(https://vaadin.com/forum/thread/17171083/how-do-i-get-javascript-callback-working).

Gilberto Torrezan Filho:
Hi Bastian,

You export a method in Java using @ClientCallable, for example:

@ClientCallable
private void myFunction(){
    //do something on the server-side
}

… and then call it on the client side by using the $server object:

element.$server.myFunction();

The name of the function exported on the client-side is the same name of the method declared on the server side.

Thanks