I'm either doing something wrong or don't understand the functionality of
Rhino here.

I am creating an object in Java and trying to pass it to the JS environment
via another JS function. I set up this simplified example to try to
understand the functionality:

Scriptable jsObject = Context.toObject(new ExampleJSClass(), instanceScope);
instanceScope.put("obj0", instanceScope, jsObject);
cx.evaluateString(instanceScope, "obj0.fun1();", "test", 1, null);

    static class ExampleJSClass extends ScriptableObject {
        public void jsConstructor(){  }
        public String getClassName(){ return "ExampleJSClass"; }
        public void jsFunction_fun1(){  }
    }

Can someone help me understand what I need to do to make this work, or what
I'm doing wrong? This example throws the exception:
org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for
object. (test#1)




_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to