Orbeon Forms
  • Getting started
  • Installation
    • Logging
    • Configuration banner
    • Docker
    • Azure
    • Tomcat
    • WildFly
    • WebSphere
    • WebLogic
    • GlassFish
    • Caches
    • Replication
    • Upgrading
  • Configuration
    • Properties
      • General
        • HTTP client
      • Form Runner
        • Detail page
          • Attachments
          • Email properties
          • PDF
          • Table of contents
        • Persistence
        • Summary page
      • Form Builder
      • XForms
    • Advanced
      • Workflows
      • Session management
      • State handling
      • Client-side error handling
      • Clustering and High Availability
      • Configuring a Form Runner eXist database
      • Creating a production WAR
      • Environments
      • JavaScript and CSS assets
      • Limiter filter
      • Run modes
      • Security
        • Content-Security-Policy header
      • SAP Hybris Module
      • XForms logging
    • Troubleshooting
      • Troubleshooting with the orbeon.log
      • Memory and threads
      • Relational database logging
      • Misc
  • Form Builder
    • Form settings
      • Time window
    • Form editor
      • Form area
      • Toolbox
      • Buttons bar
      • Control settings
      • Dependent fields and sections
      • Validation
      • Choices editor
      • Publishing
      • Cut, copy and paste
      • Section and grid settings
      • Section settings
      • Grid settings
      • Quick control search
      • Repeat settings
      • Repeated grids
      • Undo and redo
      • Keyboard shortcuts
    • Formulas
      • Examples of formulas
      • Formulas inspector
      • Formulas console
    • Summary page
    • Form localization
    • Advanced
      • Edit source
      • Services and actions
        • HTTP services
        • Database services
        • Simple Actions
        • Action Syntax
        • Action Syntax examples
        • Synchronizing repeated content
      • Testing a form in web mode
      • Testing PDF production
      • Testing offline functionality
      • Email Settings dialog
      • Field-level encryption
      • Messages
      • Section templates
      • Template syntax
      • XML Schemas support
      • Extensibility
        • Extension API
        • Integration
        • Toolbox component metadata
  • Form Runner
    • Overview
      • Terminology
    • Pages
      • Landing page
      • Published Forms page
      • Forms Admin page
      • Summary page
    • Components
      • Alert dialog
      • Attachment
      • Autocomplete
      • Captcha
      • Character counter
      • Checkbox input
      • Currency
      • Date
      • Dropdown date
      • Static and dynamic dropdown
      • Error summary
      • Grid
      • Handwritten signature
      • Hidden field
      • Image
      • Image annotation
      • Image attachment
      • Number
      • Open selection
      • Repeater
      • Formatted Text / Rich Text Editor
      • Section
      • Single-selection tree
      • Source code editor
      • Time
      • US phone
      • US state
      • Video
      • Video attachment
      • Wizard
      • XForms inspector
      • Yes/No answer
    • Features
      • Automatic calculations dependencies
      • Datasets
      • Excel and XML import
      • Excel and XML export
      • Summary page Excel Export
      • Form definitions and form data Zip Export
      • Purging historical data
      • Lease
      • Localization
      • Supported languages
      • Mobile support
      • Multitenancy
      • Form Runner navigation bar
      • PDF production
        • Automatic PDF
        • Automatic PDF header and footer configuration
        • PDF templates
      • Responsive design
      • Revision history
      • S3 storage
      • Simple data migration
      • TIFF production
      • Versioning
      • Wizard view
      • Workflow stage
    • Persistence
      • Using a relational database
      • Relational database schema
      • Purging old data using SQL
      • Auditing
      • Autosave
      • Database support
      • Flat view
    • Linking and embedding
      • Linking
      • Java Embedding API
      • JavaScript Embedding API
      • Liferay full portlet
      • Liferay proxy portlet
      • Securing Form Runner access
      • Form Runner offline embedding API
      • Angular component
      • React component
    • Access control and permissions
      • Users
      • Login & Logout
      • Deployed forms
      • Form fields
      • Editing forms
      • Owner and group member
      • Organizations
      • Scenarios
      • Token-based permissions
    • Styling
      • CSS
      • Grids CSS
      • Automatic PDF styling and CSS
    • APIs
      • Authentication of server-side service APIs
      • Persistence API
        • CRUD API
        • Search API
        • List form data attachments API
        • Form Metadata API
        • Lease API
        • Reindexing API
        • Caching
        • Versioning
        • Revision History API
        • Zip Export API
        • Custom persistence providers
      • Other APIs
        • Connection context API
        • Duplicate form data API
        • File scan API
        • Form Runner JavaScript API
        • Generate XML Schema API
        • PDF API
        • Publish form definition API
        • Run form in the background API
      • Data formats
        • Form data
        • Date and time
        • Form definition
    • Architecture and integration
      • Architecture
      • Access form data
      • Integration
    • Advanced
      • Buttons and processes
        • Simple process syntax
        • Core actions
        • Form Runner actions
          • Save action
          • Send action
          • Email action
        • XForms actions
        • Predefined buttons, processes and dialogs
        • Summary page buttons and processes
      • Custom dialogs/model logic
      • Services
      • Singleton form
      • Monitoring HTTP requests
  • XForms
    • Core
      • Attribute Value Templates (AVTs)
      • Binds
      • Validation
      • Variables
      • Keyboard focus
      • XForms JavaScript API
      • Error handling
        • Detailed behavior
      • Model-Bind variables
      • XForms 2.0 support
    • Events
      • Standard support
      • UI refresh events
      • Keyboard events
      • Extension events
      • Extension context information
      • Other event extensions
    • Actions
      • Repeat, insert and delete
      • Scripting actions
      • Extensions
    • Controls
      • Label, hint, help
      • Input
      • Output
      • Text area
      • Button
      • Upload
      • Dialog
    • Submission
      • Standard support
      • JSON support
      • Asynchronous submissions
      • Caching extension
      • Other submission extensions
    • XPath
      • Type annotations
      • Expression analysis
      • Tips
      • Compatibility
      • Standard functions
      • Maps and arrays Functions
      • Extension functions
        • Core functions
        • Utility functions
        • Model functions
        • Controls functions
        • XML functions
        • JSON functions
        • HTTP functions
        • Form Runner functions
        • Other functions
        • Deprecated functions
    • XBL components
      • FAQ
      • Guide
        • XBL Tutorial
        • Bindings
        • XForms models
        • Including content
        • Event handling
        • Conventions
        • Map XBL example
        • Learning from existing components
      • Advanced topics
        • XBL Modes
        • JavaScript companion classes
        • XBL library
        • Extensions
        • Attachment controls
    • XForms tutorial
      • Introduction
      • Installation
      • The Hello application
      • The Bookcast application
        • The basic app
        • Database access
        • Polishing the app
        • Adding a feed
    • Using XForms from Java apps
  • XML Platform
    • Page Flow Controller
      • Basics
      • XML submission
      • Navigating between pages
      • Paths and matchers
      • Other configuration elements
      • Typical combinations of page model and page view
      • Examples
      • Authorizing pages and services
    • Processors
      • URL generator
      • Request generator
      • PDF to image converter
    • Resources
      • Resource managers
      • Setting up an external resources directory
    • Other
      • Binary and text documents
  • FAQ
    • Licensing
    • PE and Dev Support
    • Form Builder and Form Runner
    • Resources and support
    • Other technical questions
  • Contributors
    • Automated tests
    • Building Orbeon Forms
    • Localizing Orbeon Forms
    • Validation functions
    • Contributor License Agreement
  • Release notes
    • Orbeon Forms 2022.1.9
    • Orbeon Forms 2024.1.1
    • Orbeon Forms 2023.1.7
    • Orbeon Forms 2024.1
    • Orbeon Forms 2023.1.6
    • Orbeon Forms 2023.1.5
    • Orbeon Forms 2021.1.11
    • Orbeon Forms 2022.1.8
    • Orbeon Forms 2023.1.4
    • Orbeon Forms 2023.1.3
    • Orbeon Forms 2023.1.2
    • Orbeon Forms 2022.1.7
    • Orbeon Forms 2023.1.1
    • Orbeon Forms 2023.1
    • Orbeon Forms 2022.1.6
    • Orbeon Forms 2021.1.10
    • Orbeon Forms 2022.1.5
    • Orbeon Forms 2021.1.9
    • Orbeon Forms 2022.1.4
    • Orbeon Forms 2022.1.3
    • Orbeon Forms 2021.1.8
    • Orbeon Forms 2022.1.2
    • Orbeon Forms 2022.1.1
    • Orbeon Forms 2022.1
    • Orbeon Forms 2021.1.7
    • Orbeon Forms 2021.1.6
    • Orbeon Forms 2021.1.5
    • Orbeon Forms 2021.1.4
    • Orbeon Forms 2021.1.3
    • Orbeon Forms 2021.1.2
    • Orbeon Forms 2021.1.1
    • Orbeon Forms 2021.1
    • Orbeon Forms 2020.1.6
    • Orbeon Forms 2019.2.4
    • Orbeon Forms 2019.1.2
    • Orbeon Forms 2018.2.5
    • Orbeon Forms 2018.1.4
    • Orbeon Forms 2020.1.5
    • Orbeon Forms 2020.1.4
    • Orbeon Forms 2020.1.3
    • Orbeon Forms 2020.1.2
    • Orbeon Forms 2019.2.3
    • Orbeon Forms 2020.1.1
    • Orbeon Forms 2020.1
    • Orbeon Forms 2019.2.2
    • Orbeon Forms 2019.2.1
    • Orbeon Forms 2019.1.1
    • Orbeon Forms 2019.2
    • Orbeon Forms 2019.1
    • Orbeon Forms 2018.2.4
  • Release history
  • Use cases
  • Product roadmap
  • Index of features
Powered by GitBook
On this page
  • Events in XForms
  • Orbeon Forms support
  • Optional ev: prefix for event attributes
  • Registering event handlers
  • Non-relevant event handlers
  • Using the ev:observer and ev:target attributes
  • The ev:propagate attribute
  • The ev:defaultAction attribute
  • Top-level event handlers
  • Event handlers on XBL bound nodes
  • Event handlers within XBL bindings
  • Delayed events
  • The ev:handler attribute
  • The ev:listener element
  • Historical note: differences between specifications
  • See also
  1. XForms
  2. Events

Standard support

PreviousEventsNextUI refresh events

Last updated 1 year ago

Events in XForms

The event model of XForms is based on the specification. This is the same specification that defines how your web browser handles events in HTML documents. This is good news because it means that his knowledge is reusable between XForms and HTML/JavaScript development!

What's new with XForms is that it allows users to declaratively register event handlers following the specification. If you write HTML and JavaScript code running directly in your browser, you would typically register event handlers using JavaScript APIs. In XForms, which does not mandate JavaScript, XML Events provide a declarative alternative to using JavaScript. This usually makes it clearer how listeners are attached to XForms objects.

Orbeon Forms support

Optional ev: prefix for event attributes

The usual XForms way of using XML events is by prefixing attributes with the ev: prefix. This is in fact not absolutely mandated by XForms, and leads to heavier attribute syntax, so Orbeon Forms allows using the attributes without a namespace. The examples below usually use the ev: prefix, but most of the Orbeon Forms code doesn't.

Example with prefix:

<xf:dispatch
    ev:observer="child-instance"
    ev:event="xforms-insert"
    targetid="main-model"
    name="update-after-insert"/>

Example without prefix:

<xf:dispatch
    observer="child-instance"
    event="xforms-insert"
    targetid="main-model"
    name="update-after-insert"/>

Registering event handlers

[TODO: basic placement and ev:event support]

Non-relevant event handlers

[SINCE Orbeon Forms 2018.1]

Orbeon Forms now considers that non-relevant event handlers, that is handlers which are within non-relevant content, do not run. Previously, such handlers would run. For example the following <xf:message> actions never run:

<xf:group ref="()">
    <xf:message 
        event="xforms-ready" 
        observer="my-model">Hello!</xf:message>
<xf:group>
<xf:input ...>
    ...
    <xf:message event="xforms-disabled">I just got disabled!</xf:message>
</xf:input>
<xxf:dialog>
    ...
    <xf:message event="xxforms-dialog-closed">I just got closed!</xf:message>
</xxf:dialog>

On the other hand, the following actions run:

<xf:message 
    event="xforms-disabled" 
    observer="my-input">I just got disabled!</xf:message>

<xf:input id="my-input" ...>
    ...   
</xf:input
<xf:message 
    event="xxforms-dialog-closed" 
    observer="my-dialog">I just got closed!</xf:message>

<xxf:dialog id="my-dialog">
    ...
</xxf:dialog>

For backward compatibility, if you need a non-relevant event handler to run, you can use the xxf:if-non-relevant="true" attribute:

<xxf:dialog>
    ...
    <xf:message
        event="xxforms-dialog-closed"
        xxf:if-non-relevant="true">I just got closed!</xf:message>
</xxf:dialog>

But please note that running event handlers in non-relevant contexts can be tricky. In particular, the XPath context might be empty, and XPath variables might be undefined.

Using the ev:observer and ev:target attributes

The ev:observer attribute allows you to register event handlers by specifying an element identifier, instead of embedding the event handler within that element. This is particularly useful to register event handlers on elements, which do not allow you to directly embed XML event handlers.

<xf:model id="main-model">
    <!-- Child instance -->
    <xf:instance
        id="child-instance"
        src="my-instance.xml"/>
    <!-- Register the event handler on the child instance -->
    <xf:dispatch
        ev:observer="child-instance"
        ev:event="xforms-insert"
        targetid="main-model"
        name="update-after-insert"/>
</xf:model>

Note that you still need to use the ev:event attribute to specify to what event the handler responds. The following example shows how you can define event handlers for XForms elements anywhere in an XForms document:

<xh:html>
    <xh:head>
        <xf:model id="my-model">
            <!-- A small instance -->
            <xf:instance id="my-instance">
                <instance>initial</instance>
            </xf:instance>
            <!-- Event handler located in the model but observing an element in the view -->
            <xf:action
                ev:observer="my-group"
                ev:target="my-input"
                ev:event="DOMFocusIn">
                <xf:setvalue ref=".">new</xf:setvalue>
            </xf:action>
        </xf:model>
    </xh:head>
    <xh:body>
        <xf:group id="my-group">
            <!-- A simple XForms input control -->
            <xf:input id="my-input" ref=".">
                <xf:label>My Data</xf:label>
            </xf:input>
            <!-- Event handler located in the view but observing an element in the model -->
            <xf:action
                ev:observer="my-model"
                ev:event="xforms-ready">
                <xf:dispatch name="DOMFocusIn" targetid="my-input"/>
            </xf:action>
        </xf:group>
    </xh:body>
</xh:html>

The above example also shows how you can constrain an event handler to respond to an event dispatched to a particular target element using the ev:target attribute. Here, the event handler responds to DOMFocusIn events, but only those dispatched to the my-input control.

The ev:propagate attribute

[TODO: describe]

The ev:defaultAction attribute

[TODO: describe]

Top-level event handlers

You can place event handlers at the top-level under the <xh:body> element:

<xh:body>
    <xxf:variable name="answer" select="42"/>
    <xf:setvalue ev:event="my-event" ref="value" value="$answer"/>
    ...
</xh:body>

Previously, you had to use a top-level <xh:group> for this to work:

<xh:body>
    <xf:group>
        <xxf:variable name="answer" select="42"/>
        <xf:setvalue ev:event="my-event" ref="value" value="$answer"/>
        ...
    </xf:group>
</xh:body>

You can also explicitly register top-level handlers using the #document observer id:

<xf:setvalue ev:observer="#document" ev:event="my-event" ref="value" value="$answer"/>

NOTE: Events from top-level models do not bubble to handlers observing on #document. Arguably, they should!

Event handlers on XBL bound nodes

When using an XBL component, you can register handlers in the same way you register handlers on built-in XForms controls.

In this case, the handler is placed directly under the bound node (<fr:foo>):

<fr:foo id="my-foo">
    <xf:setvalue ev:event="my-event" ref="my-value">43</xf:setvalue>
</fr:foo>

Event handlers with the ev:observer attribute are also recognized as long as the handler is directly under the bound node:

<fr:foo id="my-foo">
    <xf:setvalue
        ev:event="my-event"
        ev:observer="my-input"
        ref="my-value">43</xf:setvalue>
</fr:foo>
<xf:input id="my-input" ref="my-value"/>

NOTE: For event handlers nested further within the bound node, the behavior is up to the XBL component. Typically, components that are containing controls, such as <xf:input>, manage event handlers as you expect!

Event handlers within XBL bindings

Event handlers on XBL bindings are very similar to regular XML Events handlers, except:

  • they use the containing element placed within the section of an XBL binding

  • attributes do not use the XML Events namespace (typically with the ev: prefix)

  • the XBL 2 default-action attribute is not supported but instead the XML Events 1 defaultAction is supported (both support the value cancel and perform)

Example:

<xbl:handlers>
    <xbl:handler
        event="xforms-focus"
        phase="target"
        defaultAction="cancel">
        <xxf:script id="xf-sf">YAHOO.xbl.fr.Currency.instance(this).setfocus();</xxf:script>
    </xbl:handler>
</xbl:handlers>

Delayed events

Support and limitations

Orbeon Forms partially supports the XForms 1.1 delay attribute on <xf:dispatch>. The limitations are:

  • Events are not combined as specified in XForms 1.1.

Until Orbeon Forms 4.10 included:

  • A delay greater than zero always incurs a round-trip with the client. This may mean higher latency and resource usage than could be expected. You are advised to use delays in the order of seconds at least.

  • A delay of 0 causes the event to be dispatched synchronously right away, as if the delay attribute is not present.

  • A non-integer value causes the action to fail with an error.

Since Orbeon Forms 2016.1:

  • Delayed events are checked for expiration before sending responses to the client.

  • A delay of 0 can be used to dispatch an event asynchronously with a guarantee that there will be no roundtrip to the client. This conforms to XForms 1.1.

  • A non-integer value causes the event to be dispatched synchronously right away. This conforms to XForms 1.1.

Event properties/context information of atomic types are now preserved and passed when the event is dispatched with a delay. Other types of event properties/context information (such as XML nodes) are not supported and will cause an error. The following types are supported:

  • xs:string

  • xs:boolean

  • xs:decimal

  • xs:integer

  • xs:double

  • xs:float

  • xs:dateTime

  • xs:date

  • xs:anyURI: converted to a string representation

  • xs:duration: converted to a string representation

  • xs:time: converted to a string representation

Extensions

The boolean attribute xxf:show-progress allows specifying whether the client must enable the loading indicator when sending back delay events from the client. The default is true and the indicator is used.

<xf:dispatch
    name="my-event"
    targetid="my-model"
    delay="2000"
    xxf:show-progress="false"/>

The ev:handler attribute

Not supported by Orbeon Forms.

The ev:listener element

Not supported by Orbeon Forms.

Historical note: differences between specifications

There are differences between some events specifications, in particular with regard to how events phases are defined hand how handlers can specify event phases.

  • DOM Level 3 Events nicely clarifies the different event phases (capture, target, and bubbling).

  • XML Events 1 phase="default" attribute means a listener is activated on the target or bubbling phase.

  • XML Events 1 does not support activating an event strictly on the target or bubbling phase.

  • XBL 2 adds a default action phase separate from the target or bubbling phases.

  • XBL 2 proposes capture, target, bubble, default-action, and unspecified values for the phase attribute. If unspecified, this means the target or bubbling phase.

  • XML Events 2 is a W3C Working Group Note and covers declarative event handling for XML

See also

Custom event context information is not supported and simply ignored (see ).

[UP TO 4.10] The xxf:progress-message attribute allows specifying a custom progress message when xxf:show-progress is true. By default, the standard progres message is used. [SINCE 2016.1] Orbeon Forms switched to using a instead of a loading indicator message, and as a result specifying a "progress message" does not make sense anymore. The xxf:progress-message attribute is deprecated: specifying it has no effect, and might be considered as an error in future versions.

For more information, see the .

Document Object Model (DOM) Level 2 Events
XML Events 2
#2579
[SINCE Orbeon Forms 2023.1]
slim loading bar
XForms specification
UI refresh events
Keyboard events
Extension events
Extension context information
Other event extensions