You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by ga...@blueyonder.co.uk on 2009/09/06 22:47:16 UTC

Re: Calling Javascript From Inside An Applet

Helder,

Many thanks for your helpful reply. I got side-tracked with this problem
shortly after posting to the list and have only just got back to looking
at it again! I can get my applet to successfully call the show_alert()
Javascript method in my HTML page if I add an onclick listener for the
circle within my applet's code, but I am also still receiving the
"show_alert() is not defined" message along with the below stack trace:

org.mozilla.javascript.EcmaError: ReferenceError: "show_alert" is not
defined. (Event attribute file:/C:/Circle.svg:-1 onclick#1)
	at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source)
	at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source)
	at org.mozilla.javascript.ScriptRuntime.notFoundError(Unknown Source)
	at org.mozilla.javascript.ScriptRuntime.name(Unknown Source)
	at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
	at script(Event attribute file:/C:/Circle.svg:-1 onclick:1)
	at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
	at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
	at
org.apache.batik.script.rhino.BatikSecurityController$1.run(BatikSecurityController.java:104)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.apache.batik.script.rhino.BatikSecurityController.callWithDomain(BatikSecurityController.java:108)
	at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
	at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
	at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
	at org.mozilla.javascript.InterpretedFunction.exec(Unknown Source)
	at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
	at
org.apache.batik.script.rhino.RhinoInterpreter$2.run(RhinoInterpreter.java:290)
	at org.mozilla.javascript.Context.call(Unknown Source)
	at org.mozilla.javascript.ContextFactory.call(Unknown Source)
	at
org.apache.batik.script.rhino.RhinoInterpreter.evaluate(RhinoInterpreter.java:300)
	at
org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(ScriptingEnvironment.java:406)
	at
org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.handleEvent(ScriptingEnvironment.java:1440)
	at
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:324)
	at
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:366)
	at
org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:266)
	at org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1014)
	at
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(BridgeEventSupport.java:403)
	at
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(BridgeEventSupport.java:339)
	at
org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(BridgeEventSupport.java:249)
	at
org.apache.batik.gvt.event.AWTEventDispatcher.processMouseEvent(AWTEventDispatcher.java:633)
	at
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchMouseEvent(AWTEventDispatcher.java:560)
	at
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(AWTEventDispatcher.java:399)
	at
org.apache.batik.gvt.event.AWTEventDispatcher.mouseClicked(AWTEventDispatcher.java:202)
	at
org.apache.batik.swing.svg.JSVGComponent$SVGListener$12.run(JSVGComponent.java:2120)
	at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:240)
	at java.lang.Thread.run(Unknown Source)

There seems to be something else that is being triggered when it detects a
mouse click on the circle, but I can't find a way to intercept/override
this and call my own code. Am I missing something here? Or perhaps a
better question is: What happens when Batik detects a user has clicked on
an SVG element that has an "onclick" hyperlink?



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Calling Javascript From Inside An Applet

Posted by th...@kodak.com.
Hi Gary,

gary.belcher@blueyonder.co.uk wrote on 09/06/2009 04:47:16 PM:

> I can get my applet to successfully call the show_alert()
> Javascript method in my HTML page if I add an onclick listener for the
> circle within my applet's code, but I am also still receiving the
> "show_alert() is not defined" message along with the below stack trace:

   So Batik doesn't do anything to try and unify the JavaScript in your
SVG File with the HTML.  So they are running in separate Java script 
interpreters.

   You might want to read the following site to see how you can 
bridge between your applet and the JavaScript in the HTML page:

http://www.raditha.com/java/javascript.php

> There seems to be something else that is being triggered when it detects 
a
> mouse click on the circle, but I can't find a way to intercept/override
> this and call my own code.

   What do you mean? we are calling your onClick handler.