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 Robert Lummert <ro...@lummert.net> on 2007/05/09 19:57:28 UTC

invoke ECMAScript-Function

How can I invoke the execution of an ECMA-Script Function from within a
Java method? My JSVGCanvas loads correctly an SVG-Document, executing
all scripts and functions on their respective internal events. I have an
update function there, that I would like to run after setting some data
from outside, as well. Any idea?

TIA,

     Robert

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


Re: invoke ECMAScript-Function

Posted by Robert Lummert <ro...@lummert.net>.
Thanks a lot, that worked!

I additionally changed "application/javascript" to "text/ecmascript"
appropriate to my script (and I think sth. like svg-standard).

> Hi Robert,
> 
> Robert Lummert <ro...@lummert.net> wrote on 05/10/2007 12:22:13 PM:
> 
>> thanks for the hint.
>> But how do I lay my hands on the  BridgeContext?
> 
>    Get it from the UpdateManager.
> 
>  Or may I not use
>> JSVGCanvas or JSVGComponent if I intend to use the Bridge? All fields
>> and methods that seem helpful to access the BridgeContext I found
>> protected (as createBridgeContext, userAgent or documentLoader).
>> Is there another way?
>> TIA,
>>
>>      Robert
>>
>>> Hi Robert,
>>>
>>> Robert Lummert <ro...@lummert.net> wrote on 05/09/2007 01:57:28 PM:
>>>
>>>> How can I invoke the execution of an ECMA-Script Function from within 
> a
>>>> Java method? My JSVGCanvas loads correctly an SVG-Document, executing
>>>> all scripts and functions on their respective internal events. I have 
> an
>>>> update function there, that I would like to run after setting some 
> data
>>>> from outside, as well. Any idea?
>>>    Get a reference to the script Interpreter from the BridgeContext;
>>> Interpreter interp = getInterpreter("application/javascript");
>>> interp.evaluate(yourEcmaScriptCodeStringHere);
>>>
>>>    If you need to reference Java Objects you might also use:
>>> interp.bindObject(ecmaScriptVarName, javaObject);
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>>> For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 


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


Re: invoke ECMAScript-Function

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

Robert Lummert <ro...@lummert.net> wrote on 05/10/2007 12:22:13 PM:

> thanks for the hint.
> But how do I lay my hands on the  BridgeContext?

   Get it from the UpdateManager.

 Or may I not use
> JSVGCanvas or JSVGComponent if I intend to use the Bridge? All fields
> and methods that seem helpful to access the BridgeContext I found
> protected (as createBridgeContext, userAgent or documentLoader).
> Is there another way?
> TIA,
> 
>      Robert
> 
> > Hi Robert,
> > 
> > Robert Lummert <ro...@lummert.net> wrote on 05/09/2007 01:57:28 PM:
> > 
> >> How can I invoke the execution of an ECMA-Script Function from within 
a
> >> Java method? My JSVGCanvas loads correctly an SVG-Document, executing
> >> all scripts and functions on their respective internal events. I have 
an
> >> update function there, that I would like to run after setting some 
data
> >> from outside, as well. Any idea?
> > 
> >    Get a reference to the script Interpreter from the BridgeContext;
> > Interpreter interp = getInterpreter("application/javascript");
> > interp.evaluate(yourEcmaScriptCodeStringHere);
> > 
> >    If you need to reference Java Objects you might also use:
> > interp.bindObject(ecmaScriptVarName, javaObject);
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: invoke ECMAScript-Function

Posted by Robert Lummert <ro...@lummert.net>.
Hello Thomas,

thanks for the hint.
But how do I lay my hands on the  BridgeContext? Or may I not use
JSVGCanvas or JSVGComponent if I intend to use the Bridge? All fields
and methods that seem helpful to access the BridgeContext I found
protected (as createBridgeContext, userAgent or documentLoader).
Is there another way?
TIA,

     Robert

> Hi Robert,
> 
> Robert Lummert <ro...@lummert.net> wrote on 05/09/2007 01:57:28 PM:
> 
>> How can I invoke the execution of an ECMA-Script Function from within a
>> Java method? My JSVGCanvas loads correctly an SVG-Document, executing
>> all scripts and functions on their respective internal events. I have an
>> update function there, that I would like to run after setting some data
>> from outside, as well. Any idea?
> 
>    Get a reference to the script Interpreter from the BridgeContext;
> Interpreter interp = getInterpreter("application/javascript");
> interp.evaluate(yourEcmaScriptCodeStringHere);
> 
>    If you need to reference Java Objects you might also use:
> interp.bindObject(ecmaScriptVarName, javaObject);
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 


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


Re: invoke ECMAScript-Function

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

Robert Lummert <ro...@lummert.net> wrote on 05/09/2007 01:57:28 PM:

> How can I invoke the execution of an ECMA-Script Function from within a
> Java method? My JSVGCanvas loads correctly an SVG-Document, executing
> all scripts and functions on their respective internal events. I have an
> update function there, that I would like to run after setting some data
> from outside, as well. Any idea?

   Get a reference to the script Interpreter from the BridgeContext;
Interpreter interp = getInterpreter("application/javascript");
interp.evaluate(yourEcmaScriptCodeStringHere);

   If you need to reference Java Objects you might also use:
interp.bindObject(ecmaScriptVarName, javaObject);


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