W3C home > Mailing lists > Public > www-forms@w3.org > April 2006

Re: XForms timer

From: Erik Bruchez <ebruchez@orbeon.com>
Date: Thu, 27 Apr 2006 10:58:04 -0700
Message-ID: <4451062C.3030903@orbeon.com>
To: Xforms W3C WG <www-forms@w3.org>

What about:

<xforms:timer id="my-timer" timeout="1000" repeat="true"/>

The timer will just fire an event, for example "xforms-timer", when 
necessary.

<xforms:timer id="my-timer" timeout="1000" repeat="true">
   <xforms:send ev:event="xforms-timer" submission="background-save"/>
</xforms:timer>

You probably need actions and/or events to start and stop a timer as well.

But it looks easier than the Javascript below, no? ;-)

-Erik

Allan Beaufour wrote:
> On 4/26/06, Erik Bruchez <ebruchez@orbeon.com> wrote:
>> If you can't do it directly with XForms, how do you do it, with Javascript?
> 
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:ev="http://www.w3.org/2001/xml-events"
>       xmlns:xforms="http://www.w3.org/2002/xforms">
>   <head>
>     <title>Timer</title>
>     <script type="text/javascript">
>       function timer() {
>         var ev = document.createEvent("Events");
>         ev.initEvent("increment", true, true);
> 	document.getElementById("setv").dispatchEvent(ev);
> 	window.setTimeout(timer, 1000);
>       }
> 
>       window.setTimeout(timer, 1000);
>     </script>
>     <xforms:model>
>       <xforms:instance xmlns="">
>         <data xmlns="">
>           <counter>1</counter>
>         </data>
>       </xforms:instance>
>       <xforms:setvalue id="setv" ref="counter" value=". + 1"
> 		       ev:event="increment"/>
>     </xforms:model>
>   </head>
>   <body>
>     <xforms:output ref="counter">
>       <xforms:label>Counter: </xforms:label>
>     </xforms:output>
>   </body>
> </html>
> 
> --
> ... Allan
> 

-- 
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/
Received on Thursday, 27 April 2006 17:58:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:03 GMT