xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Batik can not run the ecmascript
Date Thu, 12 Nov 2009 12:21:52 GMT
Hi Rana,

Rana30 <indraneel.biswas@gmail.com> wrote on 11/10/2009 10:11:59 AM:

> 1. Create a Document from a SVG file ( say WithScript.svg ) which 
contains
> the green box.
> 2. Add this Document in the SVGCanvas.
> 3. Add a EventListener green box.
> 4. Onclick event of the green box add a yellow box and ecmascript in the
> existing document.
> 
> When user clicks on the green box, the yellow box would be added in the
> existing SVG document. In this activity the ecmascript also gets added 
in
> the existing SVG document. The ecmascript only change the border color 
of
> the green box when yellow box will be clicked.
> 
> But when I clicked on the yellow box the following error occurred.
> 
>  org.mozilla.javascript.EcmaError: ReferenceError: "Init" is not 
defined.
> (Event attribute file://localhost/C:/13060ESPE07/docWithoutScript.svg:0
> onclick#1)

    Let me start by saying that this should work (Batik should support
script elements added dynamically).  So there is something in the way 
you are doing it that is tripping up Batik.

    I noticed one thing that looked potentially problematic, but I can't
tie it to the problem:

>                         window = um.
>                             getScriptingEnvironment().createWindow();

        What is this method?  All of our createWindow methods take two
arguments, also the createWindow method is protected in Batik.
Is there a reason you aren't using 'getWindow(Interpreter interp, String 
lang)'?

>              Element e = aIcon.moveToLocation( location );
> 
>              Node myN = document.importNode( e, true );
> 
>              SVGOMElement svgRoot =
> (SVGOMElement)((SVGDocument)document).getRootElement();
>              svgRoot.appendChild(myN);

        I would guess that something about the importNode
follwed by appendChild is causing the problem but I don't 
know why.  The code that handles the insertion of script
elements can be found in batik.bridge.ScriptingEnvironment
In the innerclass DOMNodeInsertedListener.  I would suggest
instrumenting that and seeing where it goes wrong...


Mime
View raw message