Created
April 28, 2010 02:58
-
-
Save avernet/381663 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Copyright (C) 2008 Orbeon, Inc. | |
This program is free software; you can redistribute it and/or modify it under the terms of the | |
GNU Lesser General Public License as published by the Free Software Foundation; either version | |
2.1 of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
See the GNU Lesser General Public License for more details. | |
The full text of the license is available at http://www.gnu.org/copyleft/lesser.html | |
--> | |
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms" | |
xmlns:f="http://orbeon.org/oxf/xml/formatting" | |
xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" | |
xmlns:widget="http://orbeon.org/oxf/xml/widget" | |
xmlns:ev="http://www.w3.org/2001/xml-events" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
<xhtml:head> | |
<xhtml:title>Dispatch with Delay</xhtml:title> | |
<xforms:model id="my-model"> | |
<xforms:instance id="my-instance"> | |
<instance> | |
<count>0</count> | |
<started>false</started> | |
</instance> | |
</xforms:instance> | |
<xforms:action ev:event="xforms-ready"> | |
<xforms:setvalue ref="started">true</xforms:setvalue> | |
<xforms:dispatch name="my-event" target="my-model"/> | |
</xforms:action> | |
<xforms:action ev:event="my-event" if="started = 'true'"> | |
<!-- Increment count --> | |
<xforms:setvalue ref="/instance/count" value=". + 1"/> | |
<!-- Dispatch new event --> | |
<xforms:dispatch name="my-event" target="my-model" delay="1000" | |
xxforms:show-progress="true" xxforms:progress-message="Autosave"/> | |
</xforms:action> | |
</xforms:model> | |
</xhtml:head> | |
<xhtml:body> | |
<xforms:output ref="count"> | |
<xforms:label>Count:</xforms:label> | |
</xforms:output> | |
<xhtml:br/> | |
<xforms:trigger> | |
<xforms:label>Start</xforms:label> | |
<xforms:action ev:event="DOMActivate"> | |
<!-- Mark that we have started --> | |
<xforms:setvalue ref="started">true</xforms:setvalue> | |
<!-- Dispatch the event after 2 seconds --> | |
<xforms:dispatch name="my-event" target="my-model" delay="1000"/> | |
</xforms:action> | |
</xforms:trigger> | |
<xforms:trigger> | |
<xforms:label>Stop</xforms:label> | |
<xforms:action ev:event="DOMActivate"> | |
<!-- Mark that we have stopped --> | |
<xforms:setvalue ref="started">false</xforms:setvalue> | |
</xforms:action> | |
</xforms:trigger> | |
</xhtml:body> | |
</xhtml:html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment