Hi SuperNiceGenius,
[email protected] wrote on 09/22/2006 01:36:45 PM:
> How do you read a SVG JavaScript variable value from Java?
You need to get the BridgeContext from the UpdateManager
(which is available from the svgCanvas). You can then get
the Interpreter from the BridgeContext with:
Interpreter interp = getInterpreter("text/ecmascript")
Then with the interpreter you can eval script:
Object o = interp.evaluate("foo");
This should return the value of the last statement.
To be honest I'm not certain I've used this method/
You can also bind a java object into the Ecmascript
world with:
interp.bindObject("foo", bar);
Then in script you can call methods on bar by referencing
'foo':
foo.setValue("Hello World");
Assuming Object bar had a method 'public void setValue(String val)'
I think this is generally a cleaner approach but it might be
harder to do depending on your script...
Good luck.
> The Java app runs a JFrame using Batik.
> I have svgCanvas object visible in my Java app and I can get the <svg>
> root element using this code:
>
> Java code snippet-----------------------
> //get the svg root element
> org.w3c.dom.Element svgRoot=this.svgCanvas.getSVGDocument
> ().getDocumentElement();
>
> EcmaScript code snippet-------------------
> var myVariable="TheValueSetByUser";
>
> My javascript sets the value I need by user interaction in SVG.
> Now I want to read in JavaScript object.
>
> How can I retrieve this JavaScript object from the Java application?
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/