XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
101
<validate>
<script>$.Tax > 0</script>
</validate>
</subform>
</template>
</xdp>
In the example above, the full name of the referenced object is
$form.Receipt.Tax
.
For scripts written in ECMAScript, the name of the current container is
this
in native ECMAScript
expressions but
"$"
in SOM expressions. For example, in the following template,
<xdp …>
<template …>
<subform name="Receipt"…>
<field name="Tax"…> … </field>
<validate>
<script
contentType=
"application/x-ecmascript"> this.value > 0
</script>
</validate>
</subform>
</template>
</xdp>
// ECMAScript
the script uses
this
inside a native ECMAScript expression to refer to the current container. Instead of
this
it could have named the current container explicitly, but it must name the correct container! For
example, the example could have used the expression:
$form.Receipt.Tax.value > 0
// ECMAScript
Or, the script could have used the
resolveNode()
method on the
$form
object as follows:
$form.resolveNode("$.Tax").value > 0
// ECMAScript
Note: all nodes in all XFA DOMs have
resolveNode()
and
resolveNodes()
methods. Furthermore, for
the types of SOM expressions described under
“Basic Object References” on page 85,
the
resolveNode()
or
resolveNodes()
method of any node can be used. However for the advanced
expressions described in this section
“Relative References” on page 100
you must use the methods of
either the
$form
object or the this object. It is recommended to use the methods of
$form
at all times to
reduce the chance of error.
Unqualified References to Children of the Container
It is possible to refer directly to a child of the current container by name. In the following example of an
XFA SOM expression embedded in a script, the current object is the
Receipt
subform, the most
immediate ancestor that is a container. This script uses a relative reference to the value of the
Tax
field,
highlighted in bold.
<xdp …>
<template …>
<subform name="Receipt"…>
<field name="Tax"…> … </field>
Home Index Bookmark Pages
Pages: Home Index All Pages