xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Praveen Nayak" <Praveen.Na...@telelogic.com>
Subject RE: Using ScriptableObject inside IE JavaScript
Date Fri, 30 Nov 2007 02:48:36 GMT
Hi Cameron,

I have an applet with the Batik viewer.
I am doing a window.showModalDialog (by getting a handle to the window from the applet) from
inside the SVG's script and passing an object I create inside the SVG's script. I have attached
an example in the zip file.

The modal window tries to access a property of the object and call a method.

Accessing the property works.
But, even calling the method by passing an empty object

	srcObj.callMethod(scrObj, "objectMethod", new Object[0]);

doesn't work. Is there something else I should be doing?

Also, at this point I wanted to know about creating Java objects in Javascript because a lot
of methods expect a Context to be passed. I don't know how to get hold of one.


Thanks,
Praveen


-----Original Message-----
From: Cameron McCormack [mailto:cam@mcc.id.au] 
Sent: Tuesday, November 27, 2007 5:51 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: Using ScriptableObject inside IE JavaScript

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: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 
--------------------------------------------------------------------------------
Telelogic Lifecycle Solutions:
Helping You Define, Design & Deliver Advanced Systems & Software 
Learn More at www.telelogic.com 

Praveen Nayak 
Technical Leader 
Telelogic India Pvt Ltd 
#58, 1- 4 HM Towers,
Brigade Road, 
560 025 Bangalore 
India 

Phone: +91 (80) 419 95800 x327 
Fax: 
Mobile phone: 
Praveen.Nayak@telelogic.com 
http://www.telelogic.com 

Telelogic - Requirements-Driven Innovation!
------------------------------------------------------------- 


The information contained in this e-mail, including any attachment or enclosure, is intended
only for the person or entity to which it is addressed and may contain confidential material.
Any unauthorized use, review, retransmissions, dissemination, copying or other use of this
information by persons or entities other than the intended recipient is prohibited.

Mime
View raw message