XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
102
<validate>
<script>Tax > 0</script>
</validate>
</subform>
</template>
</xdp>
The SOM expression Tax does not start with
"xfa"
or any of the shortcut strings so it is taken to be the
name of a child of the current object. The full name of the referenced object is
$form.Receipt.Tax
.
In the example above, the following SOM expressions are equivalent:
Tax
$.Tax
$form.Receipt.Tax
The equivalents in ECMAScript are:
this.Tax.value // ECMAScript native expression
$form.resolveNode("Tax").value // ECMAScript SOM expression
$form.resolveNode("$.Tax").value // ECMAScript SOM expression
$form.Receipt.Tax.value // ECMAScript native expression
Unqualified References to Siblings of the Container
A SOM expression can also refer directly to siblings of its container node. For example, the calculation
script for the
$form.Receipt.Total_Price
field can refer to the
Tax
and
Sub_Total
fields, using
unqualified names:
<xdp …>
<template …>
<subform name="Receipt" …>
<field name="Sub_Total" …> … </field>
<field name="Tax" …> … </field>
<field name="Total" …>
<calculate>
<script>Sub_Total +
Tax</script>
</calculate>
</field>
</subform>
</template>
</xdp>
The equivalent in ECMAScript is:
$form.resolveNode("Sub_Total").value + $form.resolveNode("Tax").value //
ECMAScript
The ability to refer to siblings with unqualified SOM expressions makes it possible to write relocatable SOM
expressions. In the following example the same script is used for calculations in both of the Detail
subforms:
<xdp …>
<template …>
<subform name="Receipt" …>
Home Index Bookmark Pages
Pages: Home Index All Pages