xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McCormack <...@mcc.id.au>
Subject Re: Using ScriptableObject inside IE JavaScript
Date Tue, 27 Nov 2007 00:20:44 GMT
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:


There’s also a mailing list / newsgroup for Rhino discussion:


Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message