Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / LiveCycle Developer Center /

Pre-populating dropdown lists in dynamic PDF forms from a back-end data source using LiveCycle ES2.5

by Jack Freudenheim

Jack Freudenheim

by Benjamin P. Lyons

Benjamin P. Lyons
  • www.twintechs.com

Content

  • Create a table in your (MySQL) database
  • Create an XSD schema using LiveCycle Workbench
  • Create a new form that is bound to this schema
  • Create the main process in Workbench
  • Where to go from here

Created

11 September 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
forms LiveCycle PDF XML

Requirements

Prerequisite knowledge

A working knowledge of LiveCycle Designer ES2 and the database of your choice (this tutorial revolves around MySQL).

 

Additional required other products

MySQL Database
A Text Editor like Notepad ++

User level

Intermediate

Required products

  • LiveCycle (Download trial)

One of the main benefits of electronic forms is their dynamic nature. A form need not be created with one set of data and then left that way indefinitely. An electronic form once wired to a back-end data source can be dynamically updated at any time. A common use of this concept is having a dropdown list in a dynamic PDF pre-populate with data from a database.

To illustrate the process we will create a simple table in a MySql database. We will then add three rows into the database table, and we will create a simple PDF form in Designer that will include a drop-down list that is automatically pre-populated by this data source.

This tutorial describes using a MySql database as the back-end data source, though the general principles in binding this data source to the form are the same despite which back-end LiveCycle-compliant database you choose to use. This tutorial also assumes that you are familiar with how to create and edit tables in MySql and will not cover those topics in depth, as the main focus of this tutorial is how to bind these data sources to the dropdown list form object.

Create a table in your (MySQL) database

The first step is to create a table in your database. This table stores the values that will eventually appear in the dropdown list object:

use adobe; drop table testUsers; delimiter $$ CREATE TABLE `testUsers` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `complete` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=106 DEFAULT CHARSET=utf8$$ insert testUsers values (100, 'Jim Jones', 0); insert testUsers values (200, 'Sally', 0); insert testUsers values (300, 'Fred Fennel', 0); select * from testUsers  

Create an XSD schema using LiveCycle Workbench

The next step is to create an XSD Schema document. There are two ways to do this.  In both options, the first step is to create a “schema” folder in your LiveCycle project hierarchy in Workbench. Once the folder has been created, complete one of the following actions to create a schema:

  • Option One:  Right-click on the newly created “schema” folder and opt to create a new XML schema file.  Workbench will open the default text editor associated with Workbench and the new file (a text file) will have the appropriate doctype declaration and base schema tag structure in place for an XML schema. You can then use the editor to write the rest of the schema code and then save the schema document (being sure to use the “.xsd” file extension).
  • Option Two: Create the schema document using a third-party editor like Notepad ++. The benefit of using an editor like Notepad++ is once you put in your XML doctype declaration at the top of the text document in the editor, the editor uses color to make coding easier. Once the file has been created, name the schema accordingly and be sure to save the schema with the “.xsd” file extension. At this point, you will need to drag the XSD file (from wherever you saved it after editing) and drag and drop the document into your schema folder.

In either event, you will need to create a simple schema document as displayed in the schema below. 

Note, though the firstName and lastName items are in the pictured schema, these are not required for the drop-down list population. The important part of the schema code for this tutorial is the testerList element. 

Note also that this item is a complexType that has a sequence of “Tester” sub-elements, this “Tester” type in turn, is also a complexType that contains a series of values that include the “id” and the “name” for the objects that will eventually appear in the dropdown list.

<?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="FormSchema"> <xs:complexType> <xs:sequence> <xs:element name="firstName" type="string" /> <xs:element name="lastName" type="string" /> <xs:element name="selectedTester" type="string"/> <xs:element name="testerList"> <xs:complexType> <xs:sequence> <xs:element name="Tester" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="id" /> <xs:element name="name" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

Create a new form that is bound to this schema

For the sake of brevity, this tutorial assumes that the reader is able to create a new form using Designer from Workbench or directly in Designer. At this point in the process, create a new form (or open the existing form to which you want to bind the backend data) and open the form for editing in Designer. 

Bind the XSD schema data connection to the form

Once the desired form is opened, click on the “Data View” tab, by default this tab is located on the left-hand side of the Designer IDE, two tabs over from “Hierarchy”.

Right click on the whitespace of this “Data View” tab, and click New Data Connection. 

In the window that pops up (see Figure 1), name your new connection something appropriate (though the naming of this object is arbitrary to the task at hand), and select the  “XML Schema” radio button and press the “Next” button.

Figure 1. New Data Connection dialog box
Figure 1. New Data Connection dialog box

Then simply point to the schema document location. If you are following the steps directly in this tutorial, this location will be the “schema” folder in your Workbench hierarchy (see Figure 2).

Figure 2. Open XML Schema File dialog box
Figure 2. Open XML Schema File dialog box

Alternatively, if you decided to create the new form using Designer from Workbench, you are given the option to specify the form data model, which allows you to simply point to this schema (see Figure 3).

Figure 3. The New Form wizard
Figure 3. The New Form wizard

Accept the defaults for the remaining views in the Wizard.

Drag a drop-down list object onto the form

Create a drop-down list by dragging/dropping the drop-down list object onto the body of the form from the Object Library Pallete (see Figure 4).

Figure 4. Dragging objects in Designer.
Figure 4. Dragging objects in Designer.

Once the drop-down object has been dragged onto the form, click on the “Tools” menu located at the top of the Designer IDE. Select “Options” under this “Tools” menu. In the “Options” popup that appears, navigate to the “Data Binding” selection in the menu to the left. Verify that the “Show Dynamic Properties” option is checked, and then click the “OK” button (see Figure 5).

Figure 5. The Options dialog box
Figure 5. The Options dialog box

Bind the drop-down list object to the repeatable element in the schema

Navigate back to the drop-down list in the body of the form and click on it. In “Object” Pallette for the drop-down list (by default in the lower right-hand side of the Designer IDE, two tabs over from “Layout”)  and navigate to the “Field” subtab (See Figure 6).  

In the middle of this tab, click on the green “ListItems:” link object.

On the “Items” line, click on the “navigation” object to the right of the “Items” input field.  Navigate to the “Tester” level of hierarchy. The data input field should populate with the following value:  $record.testerList.Tester[*]

Figure 6. Setting List Item Properties
Figure 6. Setting List Item Properties

Notice the “[*]” convention that is used here, this convention is used whenever a schema element is going to be iterated over multiple times. Remember that in the schema, we had a segment that looked like this (see Figure 7):

Figure 7. A closeup look at the testerList schema item
Figure 7. A closeup look at the testerList schema item

When we bound this schema to the drop-down list object, we bound it at the “Tester” level of schema hierarchy. Notice also how this element has a maxOccurs attribute value set to unbounded. This attribute value must be set in the schema in order for the “[*]” convention to work in LiveCycle.

Lastly, note how there are only two element values—one for “name” and one for “id” in the schema. These elements are bound to the “testUsers” section of the database which looked like this: testUsers values (100, 'Jim Jones', 0). Remember that there were three testUsers in the database (Jim, Sally and Fred), yet here we only have one “Tester” element that contains the “id” and “name” elements. These elements correspond to the “100” (id) and “Jim Jones” (name) values in the database (we will show how the schema is connected to the database in the following section). Just understand that the “[*]” convention, when bound to the maxOccurs=”unbounded” element in the schema, will iterate through the database table and “for each” item that it iterates over in the table, it will grab that value, conform it to the data standards that the XSD is defining, and then using the schema binding to the form, populate the drop-down list field accordingly.

There are still a few more steps to complete the binding procedure. The next step is to click on the “Binding” tab under the “Object” Pallete.  Next to the “Data binding” input field, again click on the “navigation” icon to the right. Hover your mouse over the “Use ‘Data Connection’” item (see Figure 8). A side popout appears populated with the values from the elements in the schema. 

Figure 8. Binding to schema elements
Figure 8. Binding to schema elements

When the user chooses an item in the dropdown list, this binding will store the chosen ID into the “selectedTester” element, so click on this name in the list.

In the “Binding Properties” popup that appears (see Figure 9), choose which properties you would like to update on the drop-down list item.  For most circumstances, one can opt to not update any properties, or as we have opted here, to update the “Name” field of the LiveCycle form object (simply done for the sake of consistency between the form object names and the schema element names). 

For the most part we let LiveCycle handle the Caption and Type information; if you were to leave these boxes checked, it would overwrite the data in the LiveCycle form. For instance, if you map a “Date” field of “date” type to a schema element that has the “Date” element cast to a “xs:string” and leave the “Type” option checked in this dialog box, it would overwrite the type information on the “Date” object to be string. We often leave schema elements as “xs:string” values in order to allow the schema to be a bit more forgiving in the data typing, and leave the structuring of the data to the built-in data typing and validation tools within Designer.

Figure 9. Setting Binding Properties
Figure 9. Setting Binding Properties
At this point, save the form and exit Designer.

Create the main process in Workbench

Now we’ll create a main process in Workbench, then a pre-render process where we’ll execute our database lookup. This is how the database will interface with the drop-down list form object via the schema.

In Workbench, right-click on the desired location in your hierarchy and create a new process (i.e.: in a “processes” folder) using the “New Process” wizard (see Figure 10). Follow the wizard to create a new process, telling it to create a start point in the Workspace.

Figure 10. The New Process wizard
Figure 10. The New Process wizard

Note: Since this is a simple example, we didn’t use a “processes” subfolder in the “PrepopulationExample” application, but as larger, more robust applications are developed, it is recommended that you organize processes and other assets accordingly for ease of use.

Accept the defaults for the remaining steps in the wizard.

Designate the start point and prepare the data process

In the process designer, select the green “Start Point,” then in the Properties pane, click on the button to the right of the Action Profile as seen here (see Figure 11):

Figure 11. A look at the Action Profile setting
Figure 11. A look at the Action Profile setting

In the dialog box that pops up, click the button next to “Prepare data process” to launch the “New Prepare Data Process” dialog box (see Figure 12).

Figure 12. The New Prepare Data Process dialog box
Figure 12. The New Prepare Data Process dialog box

Accept the default values, and click the “OK” button twice to get out of the dialog boxes and back into Workbench proper.

Add and Configure a JDBC activity to the process

In the “NewForm1PrepareData” process, add a JDBC activity (Java Database Connector) of type “Query for Multiple Rows as XML”. The data source is automatically set to your primary data source (see Figure 13).

Figure 13. Configuring the JDBC
Figure 13. Configuring the JDBC

Click the “Sql Statement” button and fill out the dialog box (see Figure 14):

Figure 14. The SQL Statement Info Editor
Figure 14. The SQL Statement Info Editor

To see if you have successfully established the connection, press the “Test” button and you should have the “id” and “name” results returned (as pictured above); this indicates a good query.

Map database columns to the XSD schema elements

Once again navigate back to the Process Creation view, click on the “JDBC” object and click on the “XML information” in the pane to the right in order to get the dialog box pictured below, which should be filled out as such (see Figure 15):

Figure 15. The XML Document Info Editor
Figure 15. The XML Document Info Editor

Once the top section of this dialog box has been completed, press the “Test” button to verify a good connection  The desired result is the XML illustrated in the bottom white box. As you can see, we’re mapping database “columns” to XML “elements,” and in our case we’re leaving the names the same though they need not be.

Create a new XML variable

Now that the data connection has been established and bound to the schema, we need to create a variable in order to more easily manipuate the returned data.  To do this, press the Add Variable (“+” ) button next to “Output” and create a new variable of “Type: XML” and name it “Testers” (see Figure 16). This variable will now store the XML values resulting from the database query.

Figure 16. Creating a new XML variable
Figure 16. Creating a new XML variable

Create an “Assign Value” activity

Next, create an “Assign Value” activity, which we’ll use to move the XML output of our query into the “Testers” XML variable that will in turn be used to populate the form.  Connect this “Assign Value” activity to the JDBC object as illustrated in the picture below (see Figure 17).

Figure 17. Creating an Assign Variable Activity
Figure 17. Creating an Assign Variable Activity

Click on the “Activity” object and in its property pane, click the “Pencil” edit icon in the “Mappings” section, to bring up the edit dialog box. Here we assign the “Testers” variable into the appropriate place in our output variable, as below (see Figure 18):

Figure 18. Setting the destination location
Figure 18. Setting the destination location

The destination Location is:

/process_data/xmlPrepareData/xdp/datasets/data/FormSchema/testerList

Now save the process.

Deploy the application

Now, you are ready to deploy the application. Running it in Workspace, you’ll see the populated drop-down list in the form, like this (see Figure 19):

Figure 19. A look at a populated dropdown list
Figure 19. A look at a populated dropdown list

That’s it, you have successfully populated the drop-down list with the database values.

Test the “selectedTester” variable

If you’d like to prove out that the “selectedTester” variable is being set with the user’s choice from the drop-down list, you can temporarily create a text input by going back into Designer, and dragging that field from the Data View onto the form (see Figure 20):

Figure 20: Testing the “selectedTester” variable
Figure 20: Testing the “selectedTester” variable

Save the form, deploy and run again. You’ll see that the Selected Tester field will echo the ID of the user you choose from the dropdown list (see Figure 21).

Figure 21. A look at a successful test result
Figure 21. A look at a successful test result

The next step might be to use the data entered or chosen by the user and insert it into a database table.

Where to go from here

The tutorial above illustrated the principle behind creating a database table, binding it to a schema, binding the schema to a form and the creation of XML variables to store the returned data.

For further information on similar topics, check out Binding an XML Schema Document (XSD) to repeating subform elements using Adobe LiveCycle Designer.


This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.

More Like This

  • Using dot leaders in LiveCycle Designer ES Update 1
  • Binding an XML Schema Document (XSD) to repeating subform elements using Adobe LiveCycle Designer
  • Introduction to typography enhancements in LiveCycle Designer ES Update 1
  • Introduction to hyphenation in Adobe LiveCycle Designer ES Update 1
  • Displaying a list of participants for a review stage in e-mail for Managed Review & Approval Solution Accelerator 9.5
  • Foundation Form Creation excerpt: Getting into advanced form design
  • Authoring LiveCycle forms for the iPhone
  • Transforming JDBC service output using the Query for Multiple Rows as XML operation
  • Using the Execute Script Service in LiveCycle Workbench ES2 to build XML data
  • LiveCycle Designer ES form fragment tutorial

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement