What I want to do:
- I want to call a javaScript function from a Bean-function
- Then I want to pause my Bean-function
- Then the JavaScript function do it's own thing and returns stuff back to the bean
- Then the Bean-function wakes up and handle the result
Details:
- I am using JSF 2.2, and ICEfaces 4.2.0.
- I am using JavaScriptRunner.runScript() to call a javascript function. (This works well)
- Calling bean function from JavaScript works well
- According to the docs about JavaScriptRunner.runScript() the function should "Send immediately Javascript code to the client for evaluation and execution"
Problem:
- The problem is that the javaScript function won't be called before the bean code has ended.
Is it possible to start the javaScript function by interrupting the bean-function?
EDIT:
Added an example Bean of how I how thought it should work, if it helps:
public class MyBean {
public String callJavaScriptFunctionAndWaitAndHandleResult() {
// Call a javascript function from the bean
callJavaScriptFunction();
// Waits untill the javascript has returned some stuff
pause(); // <-- IS IT POSSIBLE TO WAIT HERE AND RUN A JAVASCIPT FUNCTION?
// Handle the result you got from the javascript function
handleResultFromJavaScript();
}
}