JavaScript function invocation in Java Code

Skip to first unread message

Mar 13, 2013, 11:31:06 AM3/13/13
I pass a function from JavaScript file into Java code. JavaScript function looks like:

entity.handler = function(arg1, arg2) {
//do something
In Java code the class implements the Scriptable interface. And when I invoke the JavaScript, actually the following method is invoked in Java:

Scriptable.put(java.lang.String s, org.mozilla.javascript.Scriptable scriptable, java.lang.Object o)

where for my case:

s = 'handler';

scriptable - object whose type is com.beanexplorer.enterprise.operations.js.ScriptableEntity

o - actually is a function, its type is org.mozilla.javascript.gen.c15, ( o instanceof Scriptable ) returns true in debugger.

In the Scriptable.put() method implementation I want to delegate action to the 'o' object:

SomeClass.invoke( new SomeListener(){
public void someAction(int arg1, float arg2) {
//here I need to delegate to the 'o' object.
//do something looked like:, arg2); // have no idea how to do it, if it's possible.
How can I do it? I cannot find any example needed for my case.

Reply all
Reply to author
0 new messages