Hi all,
I have a question about dynamically create javascript objects:

I have a jscript stream I *can't change, *like this:

var msg = "hello";

function printMsg(){

alert(msg);

}


And I would like declare an object (ex. "printer") to execute scripts like
"printer.printMsg()".

I've try many things like:

Script scriptObjectPrinter =
(Script)context.compileString([STREAM],"printer",1,null);

Object o = scriptObjectPrinter.exec(context, newScope);
scope.put("printer", scope, o);

//Another option
//ScriptableObject.putProperty(scriptObjectPrinter, "printer",
scriptObjectPrinter);

Script scriptObjectEx =
(Script)context.compileString("printer.printMsg();","script",1,null);

          scriptObjectEx.exec(context, newScope);

But I can't create the objects structure in Rhino context.

Anyone have an idea?

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

Reply via email to