The Mobilengine form language
The form language is an XML-based declarative language for describing a dynamic user interface for
Mobilengine forms running in the browser. form
is the root element of a
form, which contains controls and various other
elements.
Controls
Data input and data display controls are the basic building blocks of forms, and so the language as well. Controls are specific user interface elements that are displayed as a unit (such as textboxes or datepickers), and may contain child controls. Controls are declared in the language as XML elements.
Fields
Fields define the behavior (such as their display width) of the control elements that they are declared as XML attributes for. Fields are static - their values cannot be changed at runtime.
Properties
Properties store the data that is displayed and manipulated in the user interface, declared as XML attributes of a control. Their values can change during runtime.
Some properties, such as the title
of chapter
or popup
controls, specify what is
displayed in the form. The value of these properties can change only through data-binding.
Figure 199. The chapter
control's title
property is
data-bound to the tbFoo
textbox
control's text
property
Other properties, like the text
of a textbox
control, are
directly user-editable, and store the actual form data that is submitted with a form. The
value of such properties can change through either data-binding, or user
input.
Properties can be set up as both the source and (if they aren't read-only, such as
selectedText
or rows
) the
target of
data-binding.
Traits
Declared as XML elements with child elements, traits mark places in the XML hierarchy where
structured content is allowed, such as child controls, validator
s, or
let
elements that declare
variables.
Elements
A special type of XML elements that are not displayed in the user interface, but affect
form functionality in various ways. if
elements dynamically
show or hide one or more controls, let
elements declare
variables, and validator
elements attach validation rules to one or more
controls.
Figure 203. If the validation rule declared in the validator
element is not
met, an error message is displayed
Data-binding
Data-binding adds dynamic behavior to the user interface. The values of control properties are assigned in the language using data-binding expressions.
Data-binding expressions can reference and manipulate data from reference tables or other control properties. Data-bound value assignment is dynamic: whenever the input data changes, as a result of user input, for example, all dependent data-binding expressions are recalculated, and their target properties are assigned the recalculated values.
The sample below shows a very simple data-binding scenario, where the user-input in two
textbox
controls is data-bound into the text
property of
a textview
control below
them.
When the value of a user-editable property is assigned by data-binding, user changes will overwrite the data-bound values, but all user input is lost whenever a dependency of the data-binding expression in the property changes and the expression is re-evaluated.
In the sample below, the text
of the the tbAlice
textbox
is data-bound into the tbBob
textbox
.
The
user can overwrite the data-bound text in tbBob
,
but if the source of the data-binding changes, the user input is lost.