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
          • 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
      • 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
  • Introduction
  • Extensions
  • Nested MIP elements
  • Multiple binds pointing to the same node
  • Extension XPath functions
  • Custom MIPs
  • Dynamic initial values
  • Whitespace processing
  • Deferred rebuild, recalculate and revalidate
  • Static appearance for read-only controls
  • Tips
  • Making an entire instance read-only
  • See also
  1. XForms
  2. Core

Binds

PreviousAttribute Value Templates (AVTs)NextValidation

Introduction

The XForms xf:bind element is used to point to data in the data model. It allows to associate with data:

  • an id

  • a name (see )

  • properties, called Model Item Properties (MIPs)

This serves the following functions:

  • in the model

    • determine which part of the data is valid, readonly, and relevant

    • apply calculations to the data (formulas)

    • export variables used in calculations (see )

  • in the model and in the view

    • as an indirection to the data model, with the bind attribute or the bind() function

Extensions

Nested MIP elements

[SINCE Orbeon Forms 4.3 for xf:constraint, and 4.9 for other elements]

Instead of the type, readonly, required, relevant, calculate, constraint, and xxf:default attributes, you can use nested elements:

  • xf:type

  • xf:readonly

  • xf:required

  • xf:relevant

  • xf:calculate

  • xf:constraint

  • xxf:default (see below)

All elements except xf:type (whose value is not an XPath expression but a type literal) have a value attribute. The following binds are equivalent:

<xf:bind
    ref="control-1"
    type="xf:decimal"
    xxf:default="42"
    constraint=". ge 10"
    required="true()"/>

and:

<xf:bind ref="control-1">
    <xf:type>xs:decimal</xf:type>
    <xxf:default value="42"/>
    <xf:constraint value=". ge 10"/>
    <xf:required value="true()"/>
    <xf:relevant value="$qty gt 0"/>
</xf:bind>

This enables two features:

  • the ability to specify multiple readonly, required, relevant, and constraint rules (which are combined using either a boolean "or" or a boolean "and")

Multiple binds pointing to the same node

NOTE: This is scheduled to be standardized in XForms 2.

Model Item Properties (MIPs) have a default value:

  • required: false

  • valid: true (depends on a series of conditions, including required)

  • relevant: true

  • readonly: false

The resulting value of a MIP on a given node when multiple binds touch that node is the result of a boolean combination:

  • required: boolean "or"

  • valid: boolean "and"

  • relevant: boolean "and"

  • readonly: boolean "or"

The values are also combined this way when multiple nested elements are specified on a same bind.

Consider the following example:

<xf:model>
    <xf:instance>
        <instance>
            <some-node/>
        </instance>
    </xf:instance>
    <xf:bind ref="instance()//*" required="true()"/>
    <xf:bind ref="instance()/some-node" required="false()"/>
</xf:model>

some-node's required property is here set to true, and the order of the two binds doesn't matter.

NOTE: This is the behavior with Orbeon Forms 3.9 onwards. With Orbeon Forms 3.8, the combination was based on bind order.

Extension XPath functions

  • The xxf:bind() function returns the node-set of a given bind.

    • NOTE: This is also available as a plain bind() function since it is proposed for XForms 2.0.

  • The xxf:evaluate-bind-property() function evaluates a property of a given bind.

  • The xxf:type() function returns the type of the instance data node passed as parameter.

Custom MIPs

You can place user-defined Model Item Properties (MIPs) on the <xf:bind> element.

When xxf:custom-mips is missing (see below), any attribute not in a standard Orbeon namespace is interpreted as a custom MIP:

<xf:bind ref="*" foo:bar="if (starts-with(., 'g')) then 'is-g' else 'is-not-g'"/>

The value of the attribute must be a valid XPath expression. The expression result is converted to a string to set the MIP value.

Custom MIPs have the side effect of placing CSS classes on controls bound to affected nodes. Class names are computed as the concatenation of:

  • MIP attribute prefix

  • "-"

  • MIP attribute local name

  • "-"

  • MIP value

With the example above, the following class names can be set: foo-bar-is-g or foo-bar-is-not-g.

[SINCE Orbeon Forms 4.0.1]

The model supports the xxf:custom-mips attribute, which lists the names of the custom MIPs in use. When this attribute is present, only the attributes with names listed are interpreted as MIPs. Other non-built-in attributes are ignored.

When this attribute is missing, the backward-compatible behavior is enabled and all non-built-in attributes are considered custom MIPs.

It is recommended to use the xxf:custom-mips attribute to specify which attributes are custom MIPs.

<xf:model xxf:custom-mips="foo:bar foo:baz">
    <xf:bind ref="name" foo:bar="normalize-space(.) = ''" foo:baz="42"/>
</xf:model>

Dynamic initial values

The xxf:default MIP

In XForms, default or initial values can be set by pre-populating an instance document's elements and attributes with initial data, for example:

<xf:instance>
    <form>
        <username>jdoe</username>
        ...
    </form>
</xf:instance>

For dynamic values, for example coming from request parameters or session values, there is no declarative notation and you must use xforms-submit-done, xforms-model-construct-done, or xforms-submit-ready, which is sometimes cumbersome:

<xf:setvalue
    event="xforms-model-construct-done"
    ref="username"
    value="xxf:get-request-header('MY_USER')"/>

For convenience, Orbeon Forms support an extension MIP: xxf:default. It works like the standard calculate, except that it is evaluated only once, just before the first evaluation of the calculate expressions if any.

<xf:bind ref="username" xxf:default="xxf:get-request-header('MY_USER')"/>

Forcing recalculation of initial values with the recalculate action

<xf:recalculate> supports an extension attribute, xxf:defaults, which, when set to true, forces the re-evaluation of initial values before performing the recalculation.

<xf:recalculate xxf:defaults="true"/>

The xxf:defaults attribute is an AVT and can include XPath expressions between curly brackets:

<xf:recalculate xxf:defaults="{instance()/status = 'dirty'}"/>

Evaluation of initial values upon insert

Whitespace processing

The xxf:whitespace MIP

[SINCE Orbeon Forms 2016.1]

The xxf:whitespace MIP controls whitespace trimming. When the MIP is absent, there is no whitespace trimming.

xxf:whitespace can take one of two values:

  • preserve: there is no change to the value's whitespace (the default).

  • trim: leading and trailing whitespace is removed.

NOTE: The value is static and cannot be the result of an XPath expression.

When using trim, all leading and trailing characters which are spaces, including non-breakable spaces, or ISO control characters, are removed.

Example:

<xf:bind
    id="first-name-bind"
    ref="first-name"
    xxf:whitespace="trim"/>

Processing model

xxf:whitespace processing takes place during XForms recalculate processing before xxf:default and calculate processing. This means that calculations have access to data which already had whitespace processed.

The result of xxf:default and calculate follows the xxf:whitespace MIP. This means that at the time of revalidation and refresh, all values including calculated values have up to date whitespace.

Deferred rebuild, recalculate and revalidate

XForms provides actions to force a given model's rebuild, recalculate, revalidate. As XForms specifies it, these actions have an immediate effect.

Orbeon Forms provides an extension on those actions to defer the behavior of those actions by just setting the appropriate flags defined in the XForms specification, but not actually running the actions immediately. The actions will run as needed the next time the flags are checked.

<xf:rebuild     xxf:deferred="true"/>
<xf:recalculate xxf:deferred="true"/>
<xf:revalidate  xxf:deferred="true"/>

Static appearance for read-only controls

Sometimes, read-only controls don't appear very nicely in web browsers. For example, a combo box will appear grayed out. It may be be hard to read, and there is not much point showing a combo box since the user can't interact with it. Furthermore, with some browsers, like IE 6 and earlier, it is not even possible to make disabled controls appear nicer with CSS. In order to make read-only versions of forms look nicer, Orbeon Forms supports a special extension attribute that allows you to produce a "static" appearance for read-only controls. You enable this on your first XForms model:

<xf:model xxf:readonly-appearance="static">
    ...
</xf:model>

The attribute takes one of two values: static or dynamic (the default). When using the value static, read-only controls do not produce disabled HTML form controls. This has one major limitation: you can't switch a control back to being read-write once it is displayed as read-only.

You can also set the xxf:readonly-appearance attribute directly on individual XForms controls.

See Form Runner's Preview mode for an example of this feature in action.

Tips

Making an entire instance read-only

You often want to present a form without allowing the user to enter data. An easy solution is to use the readonly MIP in the model. By making for example the root element of an instance read-only, all the controls bound to any node of that instance will appear read-only (because the read-only property is inherited in an instance):

<xf:instance>
    <form>
        ...
    </form>
</xf:instance>
<xf:bind ref="instance()" readonly="true()"/>

See also

the ability to assign a specific id attribute to a MIP and

See for details about the validation-related elements (xf:type, xf:required, and xf:constraint).

For details, see .

See .

Blog post:

Model Bind Variables
Model Bind Variables
XForms Validation
XPath Function Library
Evaluation of initial values upon insert
XForms Validation
XForms Model bind variables
Better formulas with XPath type annotations
Formulas for summing values, done right
Control required values with formulas in Orbeon Forms 4.7
Evaluation of initial values upon insert
Grid component
Required fields: more subtle than you might think
refer to it from an `