JavaScriptExecutor is now API

JavaScriptExecutor is now API

In the second milestone of RAP v2.0 we introduced a new Client API. It allows as to distinguish between different clients (web client, native android client…) and handle their specific capabilities. We added a service provider interface Client that can be acquired using the new method RWT.getClient(). Client implementations can provide different services.
One of the most requested enhancements in RAP was to provide a public JavaScript execution API. With the new Client API in place we decided to expose the JavaScriptExecutor as a service of the WebClient. For those of you, that are using the old internal JSExecutor class, you have to replace the old static call:

JSExecutor.executeJS( script );

with the new service call:

Client client = RWT.getClient();
JavaScriptExecutor executor = client.getService( JavaScriptExecutor.class );
if( executor != null ) {
  executor.execute( script );
  ...
}

Please note that the null check is obligatory, because only the WebClient provides JavaScriptExecutor service. Always execute a script with a caution. If the script throws an error, it will crash the web client. Accessing internals of the web client is strongly discouraged.
These changes are currently available only in the latest nightly RAP build and will be part of RAP v2.0M3.
P.S. BrowserHistory has been converted to a client service too.