Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 342995

Summary: Provide a public JSExecutor API
Product: [RT] RAP Reporter: Benjamin Wolff <eclipse>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: a.thanbichler, elias, fr.appel, hihn, ronald.so, ruediger.herrmann, tibersept
Version: 1.4   
Target Milestone: 2.0 M3   
Hardware: All   
OS: All   
Whiteboard: plan-version=2.0 plan-theme=alternative-clients plan-status=committed

Description Benjamin Wolff CLA 2011-04-15 11:33:54 EDT
Since there have been recent issues in the newsgroup that could be solved by using the JSExecutor, I wonder if it would make sens to provide a public API for that.

I'm using the internal JSExecutor myself to execute arbitrary JS that needs to be executed on the hole page and not only in a Browser widget (closing the page or redirect, dynamically change the browser title).

So would it would make sens to provide this class or a similar mechanism as public API or are there more appropriate measures? It would definetely add more flexibility to execute arbitrary JS code but would also expose internals.
Comment 1 RĂ¼diger Herrmann CLA 2011-04-16 08:09:14 EDT
We should also consider to provide an API that allows to read request parameters.
Comment 2 Ralf Sternberg CLA 2011-04-17 16:16:41 EDT
I agree that there should be API to execute custom script code on the client. We're going to provide a dedicated slot for this in the protocol.

However, I currently don't think that such an API should be limited to JavaScript. Even though the current RAP client can only handle JavaScript, it may become possible to execute code in different languages on a RAP client. I'm thinking about an API with an additional type parameter along the lines of <script type="text/javascript">... in HTML.
Comment 3 Ivan Furnadjiev CLA 2012-10-10 08:59:44 EDT
We implemented the JavaScriptExecutor as a web client service. Usage:
JavaScriptExecutor executor = RWT.getClient().getService( JavaScriptExecutor.class );
if( executor != null ) {
  executor.execute( javaScriptCode );
}