I have an application in which I call a java method from the javascript side, like so:
rpcProxy.myFunction(parameter);
The function is of course defined in Java and it all works OK. But now, it has become necessary to have a callback function so that i can run some code only when myFunction has finished executing, on the javascript side that is.
Now, I have never dealt with callback functions as such, the only ones I know are from jquery really, so I looked at a few javascript tutorials on callback functions - this seemed OK- and it makes almost sense, but the thing is that myFunction is of course executed in Java, so I can't figure out how to get a callback function in js executing it after that one has finished. Any idea?
On the java side:
@Override
public void myFunction(String myParameter)
{
//handling callback
com.vaadin.ui.JavaScript.getCurrent().addFunction("my.vaadin.project.fileUploader2", new JavaScriptFunction()
{
@Override
public void call(JsonArray arguments)
{
System.out.println("call() executed");
Notification.show("Received call");
}
});
}