Jump to content

XForms/Send

From Wikibooks, open books for an open world

Motivation

[edit | edit source]

You want to send a request to a web server to add additional XML data into your form. This allows different parts of an XForms to defer getting data till it is needed. This makes large forms load faster and avoids unessary network traffic.

Using the send element

[edit | edit source]

The send element has a single parameter which is submission. This must be the ID of one of the submission elements in your model.

Here is and example:

   <xf:send submission="get-additional-data"/>

If you reference this submission you will need a corresponding submission in your model.

   <xf:model>
      <xf:submission id="get-additional-data" .../>
   </xf:model>

Common Usage

[edit | edit source]

The most common usage of send is to perform incremental model loading. If you have a large form with many tabs you can wait till the user selects the tab to load the data for this tab.

In the following code fragment, if the user selects tab-5 of the form the submission to load the form data will be sent to the server.

<xf:case id="tab-5">
     <xf:action ev:event="xforms-select" if="not(instance('tab-5-data')/my-data)">
         <xf:send submission="get-tab-5-data"/>
     </xf:action>
     <h2>Tab 5</h2>
</xf:case>

See XForms/Incremental_Model_Loading for an example of how this works.

Next Page: Load | Previous Page: Range
Home: XForms