Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Different xml data sources possible?

Avatar

Level 2

Ok, after searching the forum and google a lot, i figured out, that i can specify a data file in the formproperties. When i create some sample data, i get the structure the data has to look like (does it always have to look like these, or is it possible to change these things?).

But, what i'm still tryin' to figure out:

Is there a way, to get data for special items(textfields, tables, dropdownlists, ... ) from other sources, that i (perhaps) parse or read in an initialize event of of the items? I read a lot about a javascript DOMParser and the dataObject, but before i start try'n'error-coding these, i'd like to know if its worth the time?

Or is there any other way, i'm able to read any xml data (from a file) from within an event?

any help appreciated

7 Replies

Avatar

Former Community Member

There are two levels of data binding - the binding that you have been playing with so far represents that data that is collected in the form and is used when you submit the data for processing. The second set of data binding is used for populating dropdowns or getting partial information into the form (i.e. populating fields based on a database or Web Service call). These bindings are called execute bindings. These are the bindings that you shoudl be using to do the tasks that you mentioned. Note that if you are using Reader that you must apply Reader Extensions to your form to allow for these conenctions to happen. If you are an Acrobat user there are no Extensions required.

Paul

Avatar

Level 2

for example, when i add this:

var dataO = importData("./data.xml", false);

to an event of a button, i get:

ReferenceError: importData is not defined

when the event appears.("this.importData is not a function" when replacing "importData" with "this.importData", like its written in http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf , p318)

Avatar

Former Community Member

You are looking at an AcroForm reference but are coding on an XFA form. The "this" keyword in AcroForm refers to the document object. In xfa you get to the same thing by event.target. "this " in XFA refers to the object that is executing the script hence you are getting the error. You could make the command pur xfa by using:

xfa.host.importData("./data.xml, false)

Paul

Avatar

Level 2

well, this looks like a fact that should push me in the right direction. Sorry for beeing such a noob, but the project was just given to me having never ever worked with livecycle. Try'n'error all day just with a few (not very good) tutorials and google isnt that much fun. So thx very much.

Avatar

Level 2

today i tried the:

xfa.host.importData("./data.xml", false);

i get a "general exception" at this point, which tells me that the number of arguments is wrong. If i leave out the second argument (the "false" one), i get a "NotAllowedError" exception, which tells me that security preferences deny my attempt to use that function. Where can i configure this or what am i doing wrong?

(because this one is developing away from my original problem, i opened another thread ( http://forums.adobe.com/thread/514822 ) which describes my original issue more in detail)

Avatar

Former Community Member

I do not think that you can automate the import of the data without the users intervention. Try using xfa.host.importData(). This will bring up a dialog and allow the user to select the file they want.

Paul

Avatar

Level 2

Thats the point, i especially do not want the user to interact with that part of the form.