I am executing a third party javascript file in the RhinoScriptEngine. The file contains references to methods in "this". i.e. this.getField. The file is written with the expectation that "this" is some object other than the js Window object. So now when I run the script I'm getting this error:
Cannot find function getField in object [object Global]
Using the Java ScriptEngine (Rhino), how can I change the object "this" is referring to? Thanks!
Generally, I can call something like, scriptEngine.eval(script). This works great as long as there are no references to some global "this" object. I'd like to do something similar, but where I can define what "this" is.