xforms:dispatchAdded by IBM on August 8, 2013 | Version 1 (Original)
|Dispatches a pre-defined or custom event to an XForms element indicated by an ID.
<xf:dispatch event name="event-to-dispatch" targetid="id"/>
Table 1. dispatch parameters
<xf:dispatch name="event-to-dispatch" targetid="id"/>
|event||string||The XForms event that triggers the action. |
|event to dispatch||string||The event to dispatch to the identified XForms element.|
|id||string||The XForms element that receives the dispatched event.|
The following example shows an action sequence contained with the XForms model that reverses a sequence of data elements in a container element. First, all elements except the first are copied to a temporary location and then deleted from the original container element. Next, an iteration is performed to prepend each temporary element into the original container. The action sequence is invoked by dispatching a custom event to the XForms model:
at="1" position="before" origin="."/>
<xforms:label>Reverse the data list</xforms:label>
<xforms:dispatch ev:event="DOMActivate" name="custom-reverse" targetid="M"/>
When the button is clicked by the user, the xforms:dispatch sends the custom-reverse event to the XForms model M, resulting in execution of the reversing previous action sequence.
Parent topic: XForms actions
- The xforms:dispatch action allows the form author to encode a frequently-used action sequence in one location of the form (such as in the XForms model) and then invoke the action sequence from multiple locations, much like a procedure or method call.
- Method parameters for a frequently-used action sequence can be represented using temporary instance data, which can be set using xforms:setvalue actions before the xforms:dispatch action.
- The xforms:dispatch action can also be used to dispatch a pre-defined event, such as DOMActivate, to an XForms element such as an xforms:trigger, provided it is identified with an id attribute.