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
be:

applet.executeMethod("getWindow",
null).getMember("parent").getMember("location").getMember("protocol")

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

See if this helps...

Thanks,
Praveen

-----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
hosted
> in an html page
>   I have a js file that is referenced inside the svg file that the
canvas
> has loaded. Now, I am interested in accessing the HTML DOM inside the
SVG
> Javascript.
>   I have read a previous post started by Gang Su "SVG Scripting beyond
SVG
> itself" and I would like to validate my understanding in this forum
>   Accessing the Html DOM inside the SVG Javascript is not possible by
any
> 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.
But
> then, 
>   myApplet.getDocument().all
>   evaluates to null.
>   So, even if I am able to acces the HTML document object, I cannot
its
> 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
the
> 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
in
> the HTML javascript to return back exact values I need from the HTML
to
> 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.
> 

Hi,
I'm planning on doing roughly the same thing.  I just started working
with
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
document
the applet, itself, contains.  In other words, I want to know how to
pass
either the applet object or any object in the applet that was
instantiated
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
object
from javascript when the applet is embedded within the HTML DOM, which,
of
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
applet
to the SVG document's ecmascripts?  Specifically, I'm trying to access
the
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
and
manipulate it.  Right now, I can't get a reference to it in the
javascript.

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

-- 
View this message in context:
http://www.nabble.com/SVG-Javascript-and-HTML-DOM-tf4003995.html#a120949
60
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
India

Phone: +91 (80) 419 95800 Ext 327
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