Hi Praveen. Praveen Nayak: > I have a reference of a ScriptableObject inside a JavaScript which is in > the IE's context and not Rhino's.
So does that mean you have a netscape.javascript.JSObject (for IE’s script object) wrapped in a Rhino ScriptableObject? > Trying to access a property out of the object as follows works. > > scrObj.getProperty(scrObj, "objectProperty"); > > But trying to call a method as follows, doesn't work > > scrObj.callMethod(scrObj, "objectMethod", null); > > I get an exception java.lang.nullPointerException. > > 1. From the documentation of ScriptableObject, I see that I must pass a > Java object in the place I passed null during the callMethod, but I > don't know how to get an instance of a Java object from inside > JavaScript. That third argument to callMethod() is an Object[], which is an array of values to pass to the method being called on the ScriptableObject. If you have no arguments, pass in an empty arrary: srcObj.callMethod(scrObj, "objectMethod", new Object[0]); > 2. Also, how do I access ScriptableObject class inside JavaScript? There > are a lot of static methods that I am currently accessing as instance > methods (for example getProperty). I don’t know that you can. Objects that implement Scriptable are presented to the script as described by the implementation of that interface, as opposed to other objects, whose methods and fields are reflected automatically. Why do you want to call getProperty()? Why not just actually get the property? That is: val = scrObj.objectProperty; // instead of: // val = scrObj.getProperty(scrObject, "objcetProperty"); > Is there any good documentation on how to use ScriptableObject in > JavaScript I can refer? I can only suggest the Rhino documentation: http://www.mozilla.org/rhino/ There’s also a mailing list / newsgroup for Rhino discussion: http://developer.mozilla.org/en/docs/Rhino_help -- Cameron McCormack, http://mcc.id.au/ xmpp:[EMAIL PROTECTED] ▪ ICQ 26955922 ▪ MSN [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
