0

I need to create a pdf form where you can click through different records from an xml data source, similar to the ODBC version shown here.

For ODBC the following APIs were used:

xfa.sourceSet.DataConnection.last();
xfa.sourceSet.DataConnection.first();
xfa.sourceSet.DataConnection.previous();
xfa.sourceSet.DataConnection.next();
xfa.sourceSet.DataConnection.addNew();
xfa.sourceSet.DataConnection.delete();

However xfa.sourceSet is not available with XML data connection(, at least in ES4).

How can I create this same functionality with XML Data Source?

Here is a simplified version of the form and xml: enter image description here

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book category="cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
  </book>
  <book category="children">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
  </book>
  <book category="web">
    <title lang="en">XQuery Kick Start</title>
    <author>James McGovern</author>
  </book>
  <book category="web" cover="paperback">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
  </book>
</bookstore>

If I manually change the binding for subform book (shown with the blue arrow in screenshot) to $record.book[1] the details for the second record are shown in the generated pdf. Is it possible to change the bindings via javascript?

Here is a link to a copy of the form and the xml.

JeremyK
  • 3,240
  • 1
  • 11
  • 24

1 Answers1

0

The form is bound when it is first rendered, so changing the value of the binding through Javascript isn't going to work.

Some alternatives:

Make the subform repeating and put Javascript on the buttons to hide all the instances except the relevant one.

Bind the book data to a separate hidden repeating subform and use Javascript to populate the fields from the relevant instance of the hidden subforms.

Don't bind the subform at all and use Javascript to access the data model directly to populate the fields.

JeremyP
  • 84,577
  • 15
  • 123
  • 161