logo       

RE: add script functions and event via batik api--how: msg#00069

Subject: RE: add script functions and event via batik api--how
Thank you.It really works,and yes it is better to put the script in the
cdata section.
But the  problem is how to add a event(eg.a mousedown event) to the
element I create to invoke the script function I defined as following? 

<rect x="10" y="20" width="100" style="fill:red" height="50"
 onmousedown="showDialog('onmousedown')"/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^And is it the normal way to do so
^_^? I thought there will be  methods like:

doc.insertFunction(Function f) ; 
node.insertEvent(...);



-----Original Message-----
From: Vincent Hardy [mailto:vhardy@xxxxxxxxxx] 
Sent: 2002年7月19日 16:00
To: Batik Users
Subject: Re: add script functions and event via batik api--how

Hello,

You can do something like:

Document doc = ...; // Your SVG document.
Element svg = doc.getDocumentElement();
Element rect doc.createElementNS(svgNS, "rect");
svg.appendChild(rect);
rect.setAttribute(...);
Element script = doc.createElementNS(svgNS, "script");
Element scriptCode = doc.createTextElement("function showDialog() { \n
alert('msg'); })");
script.appendChild(scriptCode);
svg.appendChild(script);


Actually, it is better practice to put your code in a CDATA section
and use the createCDATASection method to do so.

I hope this helps,
Regards,
Vincent.

still wrote:
> Hi,all:
>       I try to create a SVG DOM object via batik api.
> The SVG DOM should be look like this:
> //------------
> <?xml version="1.0" encoding="UTF-8"?>
> <svg xmlns="http://www.w3.org/2000/svg"; width="400" height="450">
> <script type="text/ecmascript">
> 
>     function showDialog(msg) {
>         alert(msg);
>     }
>     </script>
> 
> <rect x="10" y="20" width="100" style="fill:red" height="50"
> onmousedown="showDialog('onmousedown')"/>
> </svg>
> //------------
> it is easy to create the "rect" element to the svg dom tree.but I can
> not
> figure out how to add the script functions and how to add the invoke
> statement in the element rect.
> It seems I should use the package org.apache.batik.script.rhino .
> Who could show me a simple sample about it?
> Thanks in advance
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xxxxxxxxxxxxxx
> For additional commands, e-mail: batik-users-help@xxxxxxxxxxxxxx



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xxxxxxxxxxxxxx
For additional commands, e-mail: batik-users-help@xxxxxxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe