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

populated drop down does not behave as expected after reopen

Yotsuba
Registered: Aug 13 2008
Posts: 5
Answered

Hellos,

I am trying to recreate an Adobe 6 form in LiveCycle, and one of the features is a button that will populate a drop down menu with the items and values from a datasource (spreadsheet via ODBC).

In the old Adobe 6 form, once the drop down is populated, you can save the file, and the data will stay with the form without reconnecting to the data source each time the form is opened.

In the livecycle form, something wierd happens. If you only look at the drop down field, all of the items are still there, after saving and reopening the form. however, fields that a dependent on the value of the drop down field does not function properly any more. adding in code to print the value of the drop down field shows that -1 is always the selectedIndex, and that the length of the list is always 0, despite the items appearing on the form itself. more over, when I export the form data, the xml output file shows the value of the item selected from the drop down field.... which is totally inconsistent with what the values shown from the debug codes.

does anyone have any idea on this, and how i can get it to work?

the problem is not with the data connection, because I have tested it with hard values into the code(below), and the behavior is the same.

for (i=0; i<20; i ++){
f.addItem("item" + i + " - " + "desc" + i, "item" + i + " - " + i);
}

many thanks for any advise

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
LiveCyle (XFA) forms are a bit more complex than AcroForms. When you change someting in an AcroForm it becomes part of the form's permanant state. AcroForms are a kind of all in one setup, what you see in the form is what's really represented internally.

XFA forms are a very different animal. Becuase they are inteneded to by dynamic they are divided into separte parts. What you see on the screen is not exactly what's represented internally. There are two main underlying parts to an XML form, the form's template and the form's data. The template is what you create in designer. But what the user sees on the screen is a dynamic merge of the data and the template. When you save the forms you are really saving to the data model. The template part is supposed to be static, and that is where the list items are stored. The data part is only the selection of the existing items.

However there is a way to fix up a list. There are two ways you can do this. The first method is to create a hidden field that holds the list items (so they are saved in the data model) then on form initialization you fill in the list items.

The other method is to modify the items in the template model. To do this you need to use XMLData operators. Start off by locating the items in the "xfa.template" branch. You can find these manually by looking at the XML model in LiveCycle Designer. Once you've located the items node, probably with resolveNode(), then clone the first itme and use this a template to create the new items. Then remove all the old items and insert the new ones. This method takes a bit more scripting, but the changes are more permanant and don't rely on the data model.

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/]http://www.adobe.com/devnet/acrobat/[/url]

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

Yotsuba
Registered: Aug 13 2008
Posts: 5
Thank you very much for the explanations and the work arounds. I'll try them out.