xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ACE91 <adamleg...@hotmail.com>
Subject Re: How to send event from embedded Javascript to Java
Date Thu, 08 Nov 2007 23:34:25 GMT


thomas.deweese wrote:
> 
>    You can use BridgeContext.getInterpreter(<mimetype string>);
> To get the javascript interpreter, then call 
> script.Interpreter.bindObject(String name, Object obj);
> 
>    To bind an Java object into the JavaScript environment.
> You can then call methods on that Java Object from javascript.
> 

Tried this, and it didn't quite work. I think I'm not doing something right.
Here's an example of what happens:

If I do this in my Java app...

Interpreter i = BridgeContext.getInterpreter("text/ecmascript");
i.bindObject("theObject", theObject);

And then run this script in the SVG file...

<script type="text/ecmascript">
    theObject.someMethod();
</script>

It tells me the theObject is not defined. However, if I do this...

i.evaluate("theObject.someMethod();");

...then it works. So apparently, the script block in the SVG file is not
using the same interpreter as the one that I'm using in my Java program. How
do I get the interpreter that the SVG file's <script> block is using?
-- 
View this message in context: http://www.nabble.com/How-to-send-event-from-embedded-Javascript-to-Java-tf4754551.html#a13658416
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


Mime
View raw message