Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Repeat invoking of JavaScript in RAP(JavaScriptExecutor vs JavaScriptLoader)
Repeat invoking of JavaScript in RAP [message #1692871] Mon, 20 April 2015 11:02 Go to next message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
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 #1693084 is a reply to message #1692871] Tue, 21 April 2015 14:58 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
I don't understand what you mean that "it cannot see the function". But it sounds like what you need is to create a public function in a script that you load with the JSL, then call it with the JSE as often as you want.
Re: Repeat invoking of JavaScript in RAP [message #1693086 is a reply to message #1693084] Tue, 21 April 2015 15:01 Go to previous message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
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
Previous Topic:launch EMF editor with RAP
Next Topic:RAP E4 out of incubator ?
Goto Forum:
  


Current Time: Thu Apr 25 04:50:44 GMT 2024

Powered by FUDForum. Page generated in 0.02877 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top