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!!
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.
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.
Thanks a mil.
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()
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?