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: SVG Javascript and HTML DOM
Date Fri, 10 Aug 2007 16:56:26 GMT
Hi Henry,

Here is the sort of code that should serve your need.

The areas of interest for you should be:

1. gvtBuildCompleted function where the registering the applet with the
Rhino engine takes place (see the interface you need to implement).

2. executeMethod which can call methods on the HTML DOM.

So, a sample call to executeMethod from inside the SVG Javascript would


which would have been parent.location.protocol in the regular HTML Js

See if this helps...


-----Original Message-----
From: henrygillam [mailto:henrygillam@comcast.net] 
Sent: Friday, August 10, 2007 10:15 PM
To: batik-users@xmlgraphics.apache.org
Subject: Re: SVG Javascript and HTML DOM

Praveen Nayak-3 wrote:
> I have the Batik JSVGCanvas loaded inside an applet. This applet is
> in an html page
>   I have a js file that is referenced inside the svg file that the
> has loaded. Now, I am interested in accessing the HTML DOM inside the
> Javascript.
>   I have read a previous post started by Gang Su "SVG Scripting beyond
> itself" and I would like to validate my understanding in this forum
>   Accessing the Html DOM inside the SVG Javascript is not possible by
> direct means. Am I correct here?
>   I then tried accessing the HTML document object in the SVG
Javascript by
> writing this method in the applet
> public Object getDocument(){
>  return JSObject.getWindow(this).getMember("document");
> }
>   After registering the applet with the Rhino engine with the name
> 'myApplet', I am able to access this document object in the SVG JS.
> then, 
>   myApplet.getDocument().all
>   evaluates to null.
>   So, even if I am able to acces the HTML document object, I cannot
> properties or call methods on it. Is this understanding right?
> So, I have now thought of a workaround for this:
> 1. I create a method in the applet called 
>   public Object executeMethod(String methodName, Object[] args){
>  return JSObject.getWindow(this).call(methodName, args);
> }
>   2. I register the applet with the RhinoScript engine in one of them
> JGVTTreeBuilder... methods so that the svg Javascript can access the
> applet and call the above method.
>   3. In the HTML file that contains the applet, I write a method with
> above method name that would work on the HTML DOM and return the
> appropriate value back to the applet, which returns it back to the SVG
> JavaScript.
> I am hoping this approach will work, and then I keep writing methods
> the HTML javascript to return back exact values I need from the HTML
> the SVG Javascript.
>   Or is there a better way of doing this?
>   Thanks,
> Praveen
> ---------------------------------
> Got a little couch potato? 
> Check out fun summer activities for kids.

I'm planning on doing roughly the same thing.  I just started working
Batik and Rhino.  I'm interested as to how you "registered" your applet
object so that it is accessible from the javascript within the SVG
the applet, itself, contains.  In other words, I want to know how to
either the applet object or any object in the applet that was
in the applet so that it is accessible in the javascript of the SVG
document.  I've only been able to find people accessing the applet
from javascript when the applet is embedded within the HTML DOM, which,
course, is not the case for me.  

Can anyone help me by giving a detailed explanation of what they used to
pass either the applet object or    another object initialized in the
to the SVG document's ecmascripts?  Specifically, I'm trying to access
HTML DOM through the org.w3c.dom.html.HTMLDocument object grabbed by the
applet.  I want the SVG's ecmascripts to take this htmldocument object
manipulate it.  Right now, I can't get a reference to it in the

Any help would be much appreciated!  I've been working on this way too
Thanks so much!

View this message in context:
Sent from the Batik - Users mailing list archive at Nabble.com.

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

Phone: +91 (80) 419 95800 Ext 327
Mobile phone: 

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.

View raw message