XFA Host Model

Enable TXFAWidgetRuntimeOptions.ScriptOptions.EnableJavaScript to use the stateful xfa.host model through the shipped QuickJS engine

Configure application metadata through TXFAWidgetRuntimeOptions.HostModel before creating the runtime, and read the current state through TXFAWidgetRuntime.HostModel

Properties

PropertyBehaviour
name, version, appType, platform, variation, languageRead-only application metadata supplied by the embedding application
numPagesRead-only actual layout page count, including positioned content beyond field widgets
currentPageZero-based current page, checked against numPages; focusing a field selects its page
titleUnicode runtime title, limited by MaxValueChars and published with the transaction
calculationsEnabledControls automatic calculation scripts; the default is true
validationsEnabledControls validation scripts for edited values; the default is true

Application version identifies the embedding application; the library does not substitute its release number

Host state belongs to the runtime; title and page changes do not modify the original PDF object graph and are not encoded into saved XDP data

Navigation, focus and data reset

MethodBehaviour
pageUp(), pageDown()Move within page bounds and stop at the first or last page
getFocus()Returns the live focused field occurrence or null when focus is absent, removed or concealed
setFocus(fieldOrSOM)Requests focus on a visible live field occurrence; null or empty text clears focus
resetData(paths="")Restores template default values for fields selected by a comma-separated SOM list, or all fields when paths is empty; repeated instance counts and unrelated occurrences are preserved

Reset fields leave editing mode and regain valid interaction state, preventing a stale edit buffer from overwriting the reset value

Reset and Data DOM loadXML may run in the same event; their changes share the event transaction, and a failed script or exhausted budget restores data values, edit buffers, host state and script-object lexical state before a retry

Field identities follow their data occurrence when an instance manager reorders repeated subforms, and snapshot restoration preserves those logical identities

Focus lifecycle and transactions

Runtime focus changes commit and validate a pending source edit, execute source exit scripts, select the new field, and execute target enter scripts before calculation and layout settle

Focus requests made by enter or exit scripts can redirect the target; each focus drain permits 64 transitions and shares the script operation and elapsed-time budgets

Scripts see the activity through xfa.event.name; calculations and validation receive their corresponding context names

Public FocusWidget and enter/exit DispatchEvent calls use the same transactional lifecycle; ClearFocus cancels its current edit buffer before the exit lifecycle, preserving its previous cancellation behaviour

OnFocusChanged publishes ordered callbacks after commitment; intermediate redirects stay inside the transaction, and failed scripts, validation or budgets restore host state, focus, edit buffers, document values and script lexical state together

Options := TXFAWidgetRuntimeOptions.Default;
Options.ScriptOptions.EnableJavaScript := True;
Options.HostModel.Name := 'Application';
Options.HostModel.Version := '1.0';
Options.HostModel.Language := 'en-US';
Runtime := TXFAWidgetRuntime.Create(XDPBytes, 595, 842, Options);
xfa.host.title = "Order form";
xfa.host.setFocus("rows[1].quantity");
xfa.host.resetData("rows[1].quantity,rows[1].price");
xfa.host.calculationsEnabled = false;

Application effects and remaining coverage

Dialogs, printing, external navigation, import/export and HTTP effects use explicit application host transport and recorded responses; the state model itself launches no UI or network operation

Additional host dialog APIs, every Acrobat host property, dynamic synchronous reflow queries and complete SOM operators remain separate integration targets

Related APIs: TXFAHostModelState, PXFAHostModelState, HPDFXFAHostModelJavaScript and Interactive XFA Widget Runtime