Repeat invoking of JavaScript in RAP [message #1692871] |
Mon, 20 April 2015 11:02 |
|
I have a dilemma invoking some JavaScript in RAP...
If I use JavaScriptExecutor:
JavaScriptExecutor jse = RWT.getClient().getService(JavaScriptExecutor.class);
if (jse != null) {
jse.execute(useJS);
}
...then this sends the actual JS as text to the browser for immediate execution. However, the scope of the JS is not good enough, for example, I cannot call a JS function in the same JS because it cannot see the function, so I can really only process VERY simple JS using JavaScriptExecutor.
Conversely, if I use JavaScriptLoader:
JavaScriptLoader jsl = RWT.getClient().getService(JavaScriptLoader.class);
if (jsl != null) {
jsl.require(useURL);
}
...this loads and executes the JS when supplied as a resource, so scope is good, and the JS can be more complex. However, I cannot execute multiple times because it is cached by the browser and does nothing at all on a 2nd call.
Is there a way around this? To be able to call multiple times, but using a static resource JS?
Thanks, John
---
Just because you can doesn't mean you should
|
|
|
|
Re: Repeat invoking of JavaScript in RAP [message #1693086 is a reply to message #1693084] |
Tue, 21 April 2015 15:01 |
|
Thanks Tim... that's precisely what I've used as my workaround... JSL to make the library available, then JSE to execute a function within that library whenever I want - works exactly how I'd want - thanks!
---
Just because you can doesn't mean you should
|
|
|
Powered by
FUDForum. Page generated in 0.02877 seconds