These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Process a delimited value into a drop-down list and bind value

Morabe
Registered: Nov 21 2006
Posts: 20

WHY we want to do this. In the past I’ve hard coded JS arrays* to display and bind the Department and Division fields. This has worked well and has become extremely ‘popular’ with the user groups. A large number of forms already carry this coding.

However I’m concerned that if something changes in any of the values it will be necessary to manually update ALL the forms. So I’m attempting to be pro-active and develop a web service that can be accessed from each form instead!

This is the process we're trying to develop:
1. User enters their USERID into a text field and hits an execute button that will go to a web service and bring back values from a database to auto-populate 7 fields.

2. Four of the fields are drop-down lists [Department, Division, Location, and SubLocation]. Each of these fields will have two functions. [1] To automatically display the value for that specific USERID. [2] To provide a drop-list of all the other field values in case their information is out-of-date.

QUESTION: How can you bind these four drop-down fields together? For example, the sequence of events we want to automatically happen is:
- user selects the appropriate Department which causes the Division drop-down list to change to only display divisions in that department
- user selects the appropriate Division which causes the Location drop-down list to change to display only the locations for that division
- user selects the Location which causes the causes the SubLocation drop-down list to change to display only the sublocations for that location

IS THIS EVEN POSSIBLE ?? We've been able to get the 1st function working (populating the 7 fields with values from the database). But we can't figure out how to bind the fields together.

This is the code we are using to receive the data for the Department field via the web service.
<?xml version="1.0" encoding="utf-8" ?>
-
Boards and Commissions
CAO's Department
City Clerk
Community Services
EES - Env. Programs & Solid Waste
EES - Admin & Development Services
EES - Administration
EES - Fleet Facilities&Dept. Resour
EES - Roads and Transportation
EES - Wastewater and Treatment
EES - Water
Elected Officials
Environmental Services
Environmental Services - Operations
Finance and Administration
Finance and Corporate Services
Legal Services
Planning and Development

======================================================================
This is the array that is currently hard-coded into each form to bind the Division field to the Department field. (I’ve shortened the list to save space.)

var g_arrayDivisions = new Array();

//BOARDS AND COMMISSIONS
g_arrayDivisions[0] = new Array("Canadian Medical Hall of Fame", "Cross Cultural Learning Centre", "London Arts Council", "London Block Parent Program", "London Convention Centre", "London Economic Development Corporation", "London Hydro", "London Police Service", "London Public Library", "London Transit", "Middlesex-London Health

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First, please don't post this much text. It's unnecessary and difficult to read through. I believe this question could have been asked with just a few sentences.

If I understand you correctly, you want to bind "List Entries", not the value, but the entries in the list, to an external data source. Which in your case is a web service.

This is feature was first offered in Designer 7.1, which was a paid update. It is also availible in Designer 8.

Just as a test, before using the web service, create an XML file with a repeated tag. Then create a new Form in LiveCycle designer and add a dropdown to it. Look in the "Object->Field" tab. The "item" text above where you add in the list items should be green and underlined like a web link. If you click on this it will bring up a dialog for binding fields in the XML to the list items.Once you've done this you can look in the XML view and you'll see an undocumented XFA property in the Field tag called "bindItems".

Open the form in Acrobat and import the XML file that you used as the template for the data source. It will populate the entries in the dropdown.

Use the same technique for setting up the web service to populate the dropdown.

You can use different functions in the webservice to populate the different dropdowns. However, if you want this to happen at different times, using differtent input data to acquire the lists, you'll need to do some quick footwork with the JS to modify the field binding at runtime to keep the other fields from being affected by the one you're working with.

There is another way to do all of this that might be easier and cause less latency on the form interactivity. And that's to connect an invisible field to a web service function that returns all the data in a big chunk, then parse it out as you need it to populate the fields. This would be similar to the techique your using right now, except that you'd be using an invisible field as the data source instead of hard coded JS values.

Hope this helps.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Morabe
Registered: Nov 21 2006
Posts: 20
Thank you for your advice. As a newbie I didn't know the etiquette but have now been set straight and will keep all postings to a minimum.

We did the following but it didn't work:

----- form1.#pageSet[0].Page1.#subform[0].ddlSite::preOpen: - (JavaScript, client) -----------------
// set the division drop down based on the dept
app.alert("inside preopen");
//fire the webservice
xfa.connectionSet.getDivision.execute(0);
app.alert("after webservice");

If we put the above code in the validate event, the codes runs correctly but it is called several times which makes it too slow. When the code was moved into the preOpen event we get to the "after webservice" alert just before we get the following fatal error. Suggestions?

-Adobe Acrobat 8.1 has encountered a problem and needs to close. We are sorry for the inconvenience.
-Error signature: AppName: acrobat.exe; AppVer: 8.1.0.137; ModName: acroform.api; ModVer: 8.1.2.86; Offset: 000ea8e3
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
morabe wrote:
As a newbie I didn't know the etiquette but have now been set straight and will keep all postings to a minimum.
No Worries:) It makes it easier on everyone, including the Readers, if posts are short, single issue, and to the point.

There are limits on what can and should be done with certain events. For example, it's a bad idea to make layout changes on the "layoutReady" event, since this could cause an infinate loop.

I don't know what the deal with the pre-open event is, it seems like it should be an ok place to do dynamic list population. But then again, it also seems unnecessary to call the web service everytime the dropdown is used. I haven't experimented with this event. All my list initialization was done in either the Initialize event, or from an event in another control. I would suggest using the Initailze event and then calling "execInitialize()" whenever it's necessary to re-populate the dropdown.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

handao
Registered: Nov 17 2008
Posts: 7
Hi,

Could you explain a litle bit more about using the initialize event rather than using another event form:ready. e.g. I have the form in version 7.2 that execute the web service in the form:ready event and when I converted it to ES and it work fine. But when I applied the adobe livecycle designer service pack 3 then it stopped working which does not populating the user information. I recalled that I read on the forum that someone suggest to move the code to the intialize event so I did it and it really solved the problem and form is working again but I could not tell what is the difference between these 2 events. Could you please explain more so I can explain to my friend.

Thanks in advance,
Han Dao
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
These events are of course called for different reasons, and they are called in a certian order, and in certain contexts. Changes made to the form from an event have to be done carefully since a change can spawn other events. There are also certain kinds of changes that cannot be done from a particular event. Every event is different.

The initialize event is specifically for setting up the control. Changes made in this event do not automatically spawn other events. It's only called when the control is first created, unless it is explicitly called from "execInitialize()". I think FormReady is called on a dynamic form any time a layout change is made in the page. And it's called after all the changes have been made. So it is a particularly bad place to do updates since any changes could cause the form to relayout and re-spawn the FormReady event. However I could be wrong. And the event triggers have changed slightly between versions.

If you really want to know how all these things work on a particular version you need to place "console.println()" statments in all the events you want to use and watch the console window to see which events are called when.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

xrum
Registered: Feb 25 2009
Posts: 124
1. you MUST save the form as dynamic if you want things to hide/unhide :)

2. you mixed them up a bit :) the code should go on the exit even of the text box that the user is typing into.


3. it's also good practice to name your subforms, then it's easier to access different objects on the form.

i'm emailing you the form back :)

good luck :)