Sure, just add
ScriptableObject.putProperty(scope, "p1", p1);
to your code before you run the script with evaluateReader. Also, I
don't think you need to use ScriptableObject.defineClass() here at
all; it has a different intended purpose.
Attila.
On 2008.02.17., at 22:06, beadrsh wrote:
> Hi ,
> I have a class
> class person{
> String name;
> }
>
> and another class wherein i create an object of person class with set
> its member name value.
>
> public class Test {
>
>
> public static void main(String[] args) {
> try {
> Context cx = Context.enter();
> person p1 = new person();
> p1.name = "beadar";
> Scriptable scope = cx.initStandardObjects();
> ScriptableObject.defineClass(scope, person.class);
> FileReader script = new FileReader("check.js");
> Object result = cx.evaluateReader(scope, script,"<cmd>",
> 1, null);
> System.out.println(result);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
>
> What i want to know is, is there a way in check.js where i can catch
> hold of p1 instance where in i can retreive its state like for ex: do
> p1.name in the javascript.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino