Welcome!

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

Java Development

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

Executing JavaScript function via scriptEngine

Hi,

 

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,

 

Harreld.

Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Executing JavaScript function via scriptEngine

[ Edited ]

Do you want to run on Blackberry Application Development or Blackberry web works Development.....?

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

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

Re: Executing JavaScript function via scriptEngine

[ Edited ]

The intension it that it runs as a WebWorks app, where building the extension in the Application Development (Java) environment and the WebWorks part in the WebWorks development environment.

The extension itself will be included as a .jar file in the WebWorks app,

So, we're dealing with two environments here that are talking to eachother.