Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 3 min read

Support

Motivation

You have a large model and you want to incrementally load different portions of the model when they are needed. This is frequently done when you have a multi-part form and each tab needs additional data. Loading only the data for the initial tab keeps your form load times fast and avoids unnecessarily locking shared data resources.

Method

We will create a model with three separate instances, one for a list of people, one for a list of places and one for a list of things. The people will automatically be loaded into the form when the form loads. We will create triggers that will incrementally load the other portions of the model when they are needed. Each trigger
will use a submission event that does a separate HTTP get to incrementally load data into a separate instance in the model.

Here is the empty place-holder instance in the model for the places and the submission to get the places data.

id="places">

id="get-places" method="get" action="places.xml"
replace="instance" instance="places"/>

Here is the trigger (button) that gets the new model.

submission="get-places">
Load Places

Screen Image

The following are the before and after screen images. The before screen image is when the form initially loads. The after image is after the user has pressed the two triggers for loading the places and things.

Before Model Fully Loaded (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0)

After Model Fully Loaded (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0)

The above example is designed to be very easy to see how data is loaded when an event is triggered. In practice each tab in a multi-tab
form may have some data that is only needed if the users click on that tab. This is a perfect use of dynamic model loading. The example below illustrates this best-practice.

Note event log does not reload model data (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0)

Load XForms Application

Example with triggers that manually load incremental data:
Load XForms Application

Example with tab-selection events that incrementally load data
Load XForms Application

Note that in this example the event log shows that the data is only loaded once regardless of how many times the tab is selected.

Avoiding Reloads

The following is an example of how to use conditional actions to check if a instance in the model
already has its data loaded into the form:

id="places-case">
ev:event="xforms-select" if="not(instance('places')/place)">
submission="get-places"/>

Places

The if attribute of the xf:action checks to see if there is at least one place in the places instance. If there is not at least one "place" the submission event is fired.

Sample Code

xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">

Incremental Model Loading
type="text/css">body {font-family: Helvetica, Arial, sans-serif;

id="people" src="people.xml">

id="places">

id="get-places" method="get" action="places.xml"
replace="instance" instance="places"/>

id="things">

id="get-things" method="get" action="things.xml"
instance="things" replace="instance"/>

Incremental Model Loading
Not all parts of the model need to be loaded into a form when it is first loaded. For
large models, different sections can be loaded as they are needed.

People
ref="instance('people')">
nodeset="person">
ref="name"/>

Places
ref="instance('places')">
nodeset="place">
ref="name"/>

submission="get-places">
Load Places

Things
ref="instance('things')">
nodeset="item">
ref="name"/>

submission="get-things">
Load Things

XML Instance Samples

[people.xml]
[places.xml]
[things.xml]

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
விபரங்களை சரிப்பார்க்கவும்" sbutton="சேமி" cbutton="மீளமை" e1msg="கடவுச்சொல் தவறு!மீண்டும் உறுதிப்படுத்துக"> விண்ணப்பதாரர் பெயர் பிறந்த தேதி முகவரி விருப்பப்படும் நுழைவு பெயர் கைத் தொலைபேசி எண் தொலைபேசி எண் மின்னஞ்சல் முகவரி கடவுச்சொல் கடவுச்சொல் உறுதிப் படுத்து name="हिन्दी" rname="पंजीकरण फार्म" s
CC BY-SA 4.0
When you press the "Enter" key the search will automatically be executed. We will also discuss a way to have a single form display both simple search and complex search functions. ## Method We will first create a simple search input field and give it an id of "search-field". We will also add an acti
CC BY-SA 4.0
XForms, Advanced Search
CC BY-SA 4.0
It must run from a webserver. To run this application you MUST enable XForms to submit data to other domains. In FireFox this is done by adding the domains to your trusted list. This can be done by going to the FireFox "Tools" menu, selecting Preferences, selecting the "Content" tab, and adding the
CC BY-SA 4.0
Web services can be called directly from an XForms application using the **submission** element in the model. ## Connecting a web service to an Event To call a web service you first need to "wire it" up to an event. For example this can be a "submit" button at the end of a form. The submit element i
CC BY-SA 4.0
XForms, Search Amazon