Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 2 min read

Support

Motivation

You want to be able to perform various tasks at various part of the form execution.

Method

XForms is integrated with the W3C XML Event standard. This standard creates standard names for almost
all of the common events used in the lifecycle of a form. The W3C has attempted to standardize these events
and their event labels so that they can be used consistently across browsers from all vendors.

XML Event Types

The following is a listing of the XForms events. Some events are tied to individual forms controls such as input, select and textarea and some are tied to the model within the form.

EventCancelBubblesTarget
Initialization Events
xforms-model-constructNY
xforms-model-construct-doneNY
xforms-readyNY
xforms-model-destructNN
Processing Events
xforms-rebuildYY
xforms-recalculateYY
xforms-revalidateYY
xforms-refreshYY
Interaction Events
xforms-previousYN
xforms-nextYN
xforms-focusYN
xforms-helpYY
xforms-hintYY
xforms-resetYY
xforms-submitYY
DOMActivateYY
Notification Events
DOMFocusInNY
DOMFocusOutNY
xforms-value-changedNY
xforms-selectNY, or
xforms-deselectNY, or
xforms-scroll-firstNY
xforms-scroll-lastNY
xforms-insertNY
xforms-deleteNY
xforms-validNY
xforms-invalidNY
xforms-in-rangeNY
xforms-out-of-rangeNY
xforms-readonlyNY
xforms-readwriteNY
xforms-requiredNY
xforms-optionalNY
xforms-enabledNY
xforms-disabledNY
xforms-submit-doneNY
xforms-submit-errorNY
Error Notifications
xforms-binding-exceptionNY
xforms-link-exceptionNY
xforms-link-errorNY
xforms-compute-exceptionNY

Displaying Events in a Log File

One of the best ways to learn about how events get fired is to write them to a log instance and display the log at the
bottom of the form. You can do this logging while you are building and debugging your form.

Add the following instance to your model:

xmlns="" id="log">

log initialized

Whenever you want to see an event, just add an action that appends an event to the end of the log:

ev:event="xforms-deselect">
nodeset="instance('log')/event" at="last()" position="after" />
ref="instance('log')/event[last()]" value="'Tab One deselected'" />

Note that the message must be inside a pair of single quotes inside of double quotes.

At the end of the form you can display the data from the log instance by enclosing the output within a repeat.

id="event-log">
nodeset="instance('log')/event" class="log">
ref="." />

You can also style the event log with the following

#event-log {
color: DarkGray;
background-color: Lavender;
}

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
First you need to give the control you want to receive the first keystroke event an **id** attribute. For example: id="first-field"> Search The next step is to use the **xforms-ready** event to set the focus to this field using the **setfocus** element. These initial actions are usually placed at th
CC BY-SA 4.0
id="tab-bar"> appearance="minimal"> Tab One case="case-1" ev:event="DOMActivate" /> appearance="minimal"> Tab Two case="case-2" ev:event="DOMActivate" /> appearance="minimal"> Tab Three case="case-3" ev:event="DOMActivate" /> id="case-1"> ev:event="xforms-select"> nodeset="instance('log')/event" at=
CC BY-SA 4.0
Here is the code for the action itself: ev:event="xforms-delete" ev:observer="people" if="not(person)"> origin="instance('person-template')" context="."/> This says to watch the **people** instance and if there is not a person in the people instance then insert one using the person-template instance
CC BY-SA 4.0
But this creates problems when referencing data elements without specifying what model the instance is part of. Note in the example below the group element encloses the output for each model. ## Sample Program xmlns=" xmlns:xf=" xmlns:foobar=" Binds to Multiple Instances in Multiple Models type="tex
CC BY-SA 4.0
Here is a simple example of how to get a list of repeating data elements out to your screen. This is done using the repeat tag and the nodeset attribute. You use the nodeset to specify where you want to begin your listing in the model. In this case we are just using a model embedded into the page.
CC BY-SA 4.0
nodeset="//my-node"> ref=".[element1='true']"> ref="element2"/> The syntax **.[a='b']** says that from the current node if the element **a** equals the value **b** then output the elements within the group. ### Conditional Formatting of Items This same strategy can be used to enclose output in diffe