Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

loadXML problem

Avatar

Level 2
Hi



I have a form in which I call a web service to get XML and then take that XML and use xfa.datasets.data.loadXML(theXml,0,1) to load the xml into the DOM. The problem i'm having is that I need to hide/show pages after I load the xml but once its loaded I cant show/hide my pages. If I remove the loadXML() the pages show/hide so I know that the problem is coming from that method call, can someone help me please?



Thanks
10 Replies

Avatar

Former Community Member
Can you post a sample to livecycle8@gmail.com and I will have a look.

Avatar

Level 2

I am having the same issue!

No need for a sample form.
Just put a button and a text field on the form.

On button click, call loadXML() and then try setting the value of the text field, for example TextField1.rawValue = "test";

The TextField's value remains unchanged.

Any code that modifies form objects (setting values, hiding/showing objects, etc) is IGNORED after the call to loadXML.

I can't seem to find a suitable workaround.

Feedback much appreciated!!

Thanks,

Shiv

Avatar

Former Community Member

The loadXML command loads data into the dataDom. The bindings of the object are bound to nodes in the datadom. My bet is that when you issue yor loadXML command you are overwriting the current Dom and hence all of the bindings to the current object are getting clobbered and hence any changes are not what you expected. In the loadXML command there are three parameters  - the data you want to load, a bool indicating whether to ignore the root node of the xml you are trying to load and a bool that indicates whether you want to replace the current loaded nodes. So based on what you have told me so far your command should be:

xfa.datasets.data.loadXML(fieldname that holde the data.rawValue, false, false)

This will load the somedata.xml file at the root level of the datadom and will append to the existing dom.

Paul

Avatar

Level 2

Hi Paul

Thanks for the quick reply.

My command is actually: xfa.datasets.data.loadXML(payload,1,1);

payload is an XML file returned from a web service call.

Let me explain my situation:

The user fills in the form.

The data in the form is exported to XML (using the saveXML function) to a database .

The user can retrieve the data they captured previously in the form by entering a reference number and hitting Search.

A web service call is made and the XML data is retrieved from the database.

This XML file is loaded into the form using the loadXML function,

The user now has a form that looks exactly like the way they had submitted it previously... well not quite.

I want to change the text of a certain text field and also hide certain fields AFTER calling loadXML -> doesn't work!!

So there's my problem.

Any suggestions?

Thanks a mil.

Shiv

Avatar

Former Community Member

The parameter that holds the xml is a string ...I am assuming that you have defined a var called payload and are using that to pass the xml to the command.

Can you dump the data dom onto the screen to make sure that it is as it was before saving? You can either make a big multiline field and use this command to populate it:

fieldname.rawValue = xfa.datasets.data.saveXML("pretty")

or if there is not much data you can use app.alert(xfa.datasets.data.saveXML("pretty"))

This will allow us to see what is in the dom after the load ...we can then verify that the bindings are correct.

One other thought is that when you load the data it is not doing a mergeing of the data onto the form. You could force this by using th ecommand xfa.form.remerge()

Paul

Avatar

Level 2

The XML data that gets written to the datbase is xfa.data.saveXML();

This data is exactly the same when it gets retrieved from the web service call.

I even went into the database and pulled up the data that was written.

So the data isn't the problem!

When I call loadXML, the data does come back into the form.

However, as I have stated, I want to hide certain fields and set the value of a field, AFTER calling loadXML.

This is where my problem lies - the code afterwards gets ignored.

I have tried using xfa.form.remerge(), no difference!

I have tried juggling code inbetween different events (exit event of the button that was clicked, for example), but it still doesn't work.

I have tried putting code in a function and calling that function, still nothing!!

I really need to be able to manipulate form objects AFTER calling loadXML.

Please can you find a workaround or a solution to my problem?

Many Thanks,

Shiv

Avatar

Former Community Member

If you can send me the form and a sample data file I will see what I can do.

Send it to LiveCycle8@gmail.com

Please include a reference back to this forum post so I know what it is you are looking for.

Paul

Avatar

Level 2

Hi pguerett

I have sent a mail to you.

Thanks for your asistance!

Regards,

Shiv

Avatar

Level 3

For anyone looking for a solution here is what worked for me:  add the line

    xfa.form.remerge();

to the form's docReady event handler section and the new data should be remerged successfully without generating any loops.

Avatar

Level 3

It turns out that if the initial data XML does not have the node referenced by the form then it is not possible to bind to it even if the node is created after loading by an assignNode call.  Is this a bug or a feature?

Here is a fragment of the initial XML I would like to supply:


<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
    <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
        <xfa:data>
            <regRoot>
                <regauth>335523539322713</regauth>
                <nutcls>SP</nutcls>
                <ddlnutcls>
                    <codeItem code="R1" label="R1">Reservoir 1</codeItem>
   ....

There is a regAuthList node missing that contains repeating elements used to populate a drop-down list.  I can create the node from a WSDL connection perfectly using loadXML BUT the xfa.form.remerge() fails.  HOWEVER, if I change the input XML to include a regAuthList node as in the following:


<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
    <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
        <xfa:data>
            <regRoot>
                <regauth>335523539322713</regauth>
                <nutcls>SP</nutcls>
                <regAuthList/>
                <ddlnutcls>
                    <codeItem code="R1" label="R1">Reservoir 1</codeItem>
   ....

... then the xfa.form.remerge() works as desired and the drop-down list functions properly.

Updated with more detailed solution requirements: Don@NDEQ