XFA Input Event Listeners
Version 2.1205.6 also consumes handlers created through native property chains; sparse Form event overrides are matched by event occurrence, preserving inherited scripts and accepted data contexts without executing the template handler twice
Version 2.1169.0 connects native input dispatch and pending text changes to eligible ancestor listeners, including an ancestor-only listener where the field has no local script
Version 2.1181.0 also routes qualifying click and pending-change events to fields, subforms or exclusion groups whose explicit ref resolves to the source or one of its containers
Explicit references across containers
The event declaration stays on its listener owner; ref identifies the object generating the event, including an object in another container
Relative references start in the listener's accepted occurrence and data context; absolute $form paths can intentionally select a different repeated occurrence
Native literal, indexed, wildcard and parent paths use the existing Form SOM resolver; one event is admitted once even when several matching targets or physical presentations identify the same logical listener
refOnly listens to the referenced source itself; refAndDescendents also admits actual sources contained by that referenced object, independently of where the listener is declared
For a field named watcher observing an input named input, place this event inside watcher
<event activity="change" ref="$form.main.input" listen="refOnly">
<script contentType="application/x-javascript"><![CDATA[
this.rawValue = xfa.event.target.name;
xfa.event.change = "XYZ";
]]></script>
</event>
Replacing the middle of ab through ReplaceSelection(1, 0, 'q') then produces and commits aXYZb, whilst watcher records the original source name
Handlers and their resolved owners are frozen before execution; changes to references, listener properties or script declarations affect a later dispatch rather than retargeting the current one
Computed reference predicates
Version 2.1182.0 supports computed reference selectors through the same public SOM script resolver used by event scripts when ScriptOptions.EnableJavaScript is enabled and a script provider is configured
The selector parentheses determine its language: source.(Number(this.score.rawValue)>20).input evaluates JavaScript, whilst source.[score ge 20].input evaluates FormCalc
Each predicate runs with the candidate object as its current container; the eventual listener script runs with its own listener owner as this and the original input in xfa.event.target
For example, a watcher can select an input inside a sibling container whose score exceeds 20
<event activity="change" ref="source.[score ge 20].input" listen="refOnly">
<script contentType="application/x-javascript"><![CDATA[
this.rawValue = xfa.event.target.name;
xfa.event.change = "XYZ";
]]></script>
</event>
Reference expressions are evaluated once per declaration and candidate; listener declarations, references and scripts are captured before the first predicate runs, then matching handlers execute from that frozen plan
Predicate effects and handlers share the configured transaction operation and deadline limits; exceptions and exhausted limits restore XML, focus and pending edits
Removing an unrelated repeated instance refreshes accepted widget contexts before another predicate or handler resumes; removal of a source still required by pending work rolls back
A reference that matches no source does not manufacture a click listener; ordinary typed edits may still proceed without a matching change listener
Native FormCalc without a script provider
Version 2.1188.0 fixes leading class selectors in native resolveNode/resolveNodes queries; this does not change the separate event-ref compatibility route for leading XML-ID references
Version 2.1185.0 evaluates FormCalc .[...] input-reference predicates and ordinary FormCalc event handlers directly when ScriptOptions.EnableJavaScript is False, without loading a JavaScript provider
A listener with ref="source.[Sum(score,5) ge 30].input" can use application/x-formcalc to set this.presence = "invisible"; its predicate uses the source candidate whilst the handler uses the listener owner
The native language supports variables, assignments, arithmetic, comparisons, short-circuit logic, conditional blocks, loops, user functions and recursion, plus numeric, string, aggregate and reference functions
Qualified instance operations retain ordinary row.instanceManager and _row aliases; version 2.1187.0 extends manager lifetime across last-member removal, current count/min/max, setInstances and actual created-instance returns, whilst old ordinary Form references and managers beneath retired parents remain invalid
Qualifying native queries retain implicit candidate contexts through multiple Form rebuilds and nested queries, including accepted native-generated unbound repeats; an explicitly saved object reference remains retired after rebuilding
Typed-change predicates and handlers share the current UTF-16 edit selection and replacement text; saved recordless forms retain explicit no-data context, and xfa.record uses the current accepted record rather than borrowing the first record
Reference side effects run once, listener membership is frozen, and predicates and handlers share the configured operation and deadline limits; errors restore document, focus and pending edit state
Version 2.1186.0 adds native choice methods, exact selection and accepted dataNode references to ordinary event scripts
JavaScript .(...) predicates still require explicit JavaScript enablement; native FormCalc layout conditions and accepted-layout queries share transaction limits and rollback, whilst date and locale formatting functions and broader DOM/property combinations remain separate compatibility work
See native event scripting and execution budgets
Predicates that rebuild the Form
Version 2.1183.0 continues qualifying computed references when a predicate calls xfa.form.remerge(), using proved query-frame recovery for each needed current Form instance
Later candidate evaluations and path steps use the rebuilt model; completed predicate effects are retained once, whilst handlers recover their own accepted owner, original event source and pending edit
A predicate may rebuild multiple times, including whilst evaluating repeated data-bound candidates, within the existing shared transaction limits
Retired user handles remain invalid; cloned, removed or ambiguous objects cannot silently replace a candidate that lacks a unique continuation proof
Version 2.1184.0 additionally continues qualifying queries through unbound repeats with accepted native generation origins, including nested repeats, a raw candidate that rebuilds again, and successful retry after an exception rolls back both XML and generation provenance
Instances without their own binding may inherit the same nonempty data context; this differs from a genuinely recordless Form and both generated profiles are supported
Version 2.1185.0 adds the provider-free native FormCalc profile; arbitrary imported or manual repeats without native origins, generated placements and broader property-query continuation remain separate compatibility work
Listener scope
An event on the source field qualifies for its matching activity; an ancestor subform or exclusion group must additionally specify listen="refAndDescendents"
This profile resolves an omitted ref or ref="$" to the event's containing object; an ancestor with the default refOnly receives no descendant's input
The runtime freezes admitted handlers before execution, shares the configured operation and elapsed limits across them, and resolves each accepted context afresh after structural publication
Applications should not depend on a parent-first or child-first propagation order
Script owner and original target
In an ancestor script, this is the listener's accepted form occurrence, whilst xfa.event.target remains the original input source
Each occurrence keeps its own data context; a repeated listener must not borrow the leaf's data scope or a neighbouring repeated row
Nested initialisation and calculation use their own execution context rather than inheriting the outer input target
Filter pending text at a container
Place this event inside a subform holding an editable input and a field named log, and enable the runtime's JavaScript provider
<event activity="change" ref="$" listen="refAndDescendents">
<script contentType="application/x-javascript"><![CDATA[
xfa.event.change = "XYZ";
this.log.rawValue += "P";
]]></script>
</event>
For an input buffer ab, ReplaceSelection(1, 0, 'q') produces aXYZb; CommitEdit adopts the same value
All admitted change handlers receive the evolving pending edit payload, including the previous text, replacement, UTF-16 selection and computed new text
Manual DispatchEvent synthesises no typing selection and keeps its ordinary event payload
Structural changes and recovery
Version 2.1180.2 keeps the original input source available to pending listeners when removing an unrelated field causes the first complete Form materialisation, including an initially unbound data context
Template objects keep their own identities whilst live Form objects retain the accepted input identity; source retirement and ambiguity checks remain unchanged
Source and listener recovery rely on accepted declaration and data identities rather than a recycled widget index or identifier alone
A retired or ambiguous source cannot redirect the remainder of the operation to another field
A final click listener may remove its source when no remaining handler needs that context; active typed edits retain their separate requirement for a live editable target
A failing handler, an invalid edited selection, an exhausted limit or a failed context recovery restores the document, values, edit buffer and focus through the surrounding transaction
Qualification boundary
This profile covers ancestor, ordinary explicit, enabled-provider computed and qualifying provider-free native FormCalc click/change listeners with accepted context recovery; unproved imported repeats or property/generated query contexts across remerge, general repeated-instance ID mappings, generated virtual-insertion routing and other event families remain separate compatibility work
Ordinary input sources can remain event targets after becoming hidden; Versions 2.1169.2 and 2.1169.3 also retain accepted generated presentation sources across ordinary publication, proved remerge and qualified streaming barriers
Hidden-source remerge or window barriers and unproved placement contexts remain separate from that generated-source profile
Click dispatch can continue through a proved form remerge; Version 2.1169.1 also supports typed-change remerge continuation when the same accepted input and editing ownership survive
A removed or ambiguous source, a conflicting focus request or an explicit cancellation still stops the edit being restored over a lifecycle decision
Focus enter, validation and exit keep their separate ancestor focus transition model
Literal references keep their existing parser, whilst computed FormCalc references use the bounded native event evaluator when JavaScript is disabled
See Interactive Dynamic XFA Widget Runtime and TXFAEventBinding