Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

New Contributor
Posts: 4
Registered: ‎01-05-2012
My Device: 9800
My Carrier: Vodafone

Execute JavaScript function from a JavaScript Extenstion by means of ScriptEngine



I'm building a WebWorks application that uses a javaScriptExtenstion written in Java.

I'm able to address Java functions from the WebWorks part (javaScript), but now I want to do it the other way around so that the Java part can send notifications to the WebWorks part..

So from the Java part I want to call a javaScript function that is part of the WebWork part.

I know that it is possible, but I can't get to work.

The LoadFeature method of the WidgetExtension class provides a reference to the WebWorks script by means of the ScriptEngine parameter. So what I want to do is using the executeScript method of the scriptEngine class/parameter in order to call a javaScript function in the WebWorks part.

So when in the javaScript is a function:

function testfunc()


    alert( "call from Extension" );



And the LoadFeature method gets a ScriptEngine class param myScript, to my opinion it should be possible to address the javaScript function like:

myScript.executeScript( "testfunc();", null );


But for some reason this doesn't work. Sometimes the whole app even crashes.

Can anybody tell me what I'm doing wrong?

Thanks in advance and best regards,