Here's a method based on the standard (but optional) DOM Event type, MutationEvents. It took me a little while to come up with it, but I'll give it to you for free :-).
If your SVG processor supports the MutationEvents feature (you should test for this, especially if you intend to also run on non-Batik SVG engines), and has the right language bindings to the DOM (like Batik does) then you can use a <text> element (probably with visibility="hidden", and width and height="0") to which you dispatch mutation events from Java, and to which you can attach an ECMAScript listener. The new text content specified in the event data can be used to carry any kind of message you want. You can use the same technique to go from ECMAScript to Java, too. Note that: (1) Using dispatchEvent() is more efficient that actually changing the content of the <text> element. (2) The <text> element should not have display="none", since then it is not supposed to receive any events. [However, Batik currently does allow the dispatchEvent() method to send events to a <text> element having the display="none" attribute. I believe this is a bug. Also, I noticed that in Batik when you use the dispatchEvent() method to send a mutation event for a <text> element, the text element does not change its actual content, meaning that the dispatched event is lying about the new (and possibly also the old) content of the element. This is probably acceptable behavior, since the spec doesn't seem to say this can't happen, and it is more efficient. Just be sure that you don't accidentally treat the event data for such <text> elements as being real text event data.] Samuel C. Yang Echelon Corp. <http://www.echelon.com> email: <mailto:[EMAIL PROTECTED]> phone: 408-938-5314 fax: 408-790-3430 > -----Original Message----- > From: William Huang [mailto:[EMAIL PROTECTED]] > Sent: Monday, February 10, 2003 11:44 AM > To: Batik Users > Subject: Can I call Javascript function from Batik Java code? > > > I changed the SVGImageElementBridge program to make the <a> > element work as my application needs. However, I need to call > one large Javascript function of mine at the end of my > createSVGImageNode() method call. I can rewrite the > Javascript function into Java, but that costs too much > efforts. Is there a way to call Javascript function from > Batik Java implementation? Thanks a lot. > > William > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
