Expand my Community achievements bar.

Dynamic form calling webservice everytime it changes its structure

Avatar

Former Community Member

Hello all

I have a dynamic form which contains some drop-down lists that are filled via webservices (in their initialize events). It also contains a dynamic table

I have noticed that everytime I add a new row to the table the webservices are invoked again, so there's a delay for the final user to be able to enter text into the table

How can I prevent this from happening? Where should I put the code for invoking the webservice?

Thank you

20 Replies

Avatar

Level 10

From your post I assume, the dropdowns are part of Table which are added when add a new Row. So the Initialize event gets invoked every time..

Try placing a hidden field outside the Table and invoke the Webservice at the initialization and fill in the dropdown box in the intial row.

1) And in your Add Row code, just copy the data from the initial dropdown to the dropdown in newly added Row.

2) Other alternative is to set the dropdown's binding to Global so when you add the Row, bot the dropdowns have the same name so they can duplicate the data.

Thanks

Srini

Avatar

Former Community Member

The dropdowns are completely outside the table

Avatar

Level 10

See if you are using "xfa.form.remerge();" in your code after adding the Row..If it is there comment it and try..

Thanks

Srini

Avatar

Level 2

Can you call the webservice from Adobe Reader as well? if yes, is there anything special that needs to be done before the reader can call web services?

Avatar

Former Community Member

By default Reader will not allow Web Service calls, but you can Reader Extend your form to allow Reader to do this. You woudl need the full version of LiveCycle Reader Extensions server to turn on that right (the Acrobat version does not turn on this capability).

Paul

Avatar

Former Community Member

The form is rendered using Reader Extensions ES

Avatar

Level 2

I have Adobe LiveCycle Designer ES version 8.2.1

Can this be used to extend webservice calling feature in Reader? if yes, where is that option?

Thanks

Shreedhar

Avatar

Former Community Member

No you need a separate product called LiveCycle Reader Extensions Server.

Paul

Avatar

Former Community Member

So, does anyone know what's causing the webservices to be invoked again when I add a row in the dynamic table?

Should I move the code that invokes them and populate the drop-down lists from their initialize event?

Avatar

Former Community Member

What event is the code to execute your web service now?

paul

Avatar

Former Community Member

myForm.Page1.dropDown_offices::initialize - (JavaScript, client)

     xfa.connectionSet.webServiceConnection.execute(0); //nombre del connection

     xfa.datasets.data.loadXML(officesList.rawValue, false, false); //hidden field that stores the XML brought           by the webservice

     xfa.datasets.data.saveXML();

     var xmlOffices= xfa.datasets.data.resolveNode("officesList");

     var length = xmlOffices.nodes.length;

     for (var i=0; i < length; i++)

          this.addItem(xmlOffices.nodes.item(i).nodes.item(1).value);

   

     //remove the xml from the underlying form data

     xfa.datasets.data.nodes.remove(xfa.datasets.data.resolveNode("officesList"));

Avatar

Former Community Member

The Initialize event will fire each time a row is added beacuse that entire page is being layed out again. I assume that you want to run this WS on etime when the ofrm loads. If so move the code to the Doc Ready event and see if that fixes the issue.

Paul

Avatar

Former Community Member

If I place the code in docReady, then my dropdowns won't get populated

The code executes but the list is empty

Avatar

Former Community Member

At the end of your code add the command xfa.layout.relayout()

Paul

Avatar

Former Community Member

Did that, but get the same behavior, executing but not adding items to the list

Avatar

Former Community Member

I have seen this behaviour before .....if I remember right it has to do with where you are placing your xml. By putting it under the datasets.data node the product is doing a remerge and it is clearing your list because it has no values. Try changing the location to something else like xfa.datasets.loadXML.....

It might not allow you to create a node at that level. If that does not work I have an example somewhere where I load it in a different dom and the clearing of the field no longer happens.

Let me know how the test goes and in the mean time I will look for that other code.

Paul

Avatar

Former Community Member

OK, i replaced the xfa.datasets.data.loadXML with xfa.datasets.loadXML and every subsequent references now point to xfa.datasets

It seems to be working fine now, though I need to conduct a test in Workspace, I'll let you know of the final result.

Can you explain a bit further why the XML has to be on the top level? (xfa.datasets)

What does xfa.datasets.data contain?

I have seen that if you don't remove the node you inserted in the DOM, it will stick to the XML the orchestration uses, so would it be on a higher level now if I didn't remove it?

Avatar

Former Community Member

The datsets.data is the DataDom that is used to bind the fields in the form to the XML structure that will be submitted. So by putting the xml into that area it is in fact working (populating the dropdown with the values that you want). Then because you have changed the dom structure a remerge of template and data occurs and of course that DDList has no value in the dom and it clears out the list. By moving your xml load to a different area we are NOT triggering the remerge and hence your values remain behind.

Make sense?

Paul

Avatar

Former Community Member

Yeah, now I understand it what you mean by remerge and what xfa.datasets.data contains. Now it's working as expected

Is this a good practice? I have heard that you can set up an orchestration whose output variable is a List and populate the DDList right from the WS, but never been able to achieve that.

Thank you

Avatar

Former Community Member

You can do that in a Guide (flex front end to the form) but not in an actual form. The issue is that the xfa form only understands simple types (like strings, int, float). The XML is really a string and you are interpretting the result by loading it into the DOM and manipulating it. In other data connections (like OLEDB) you can bind the column of a DB to a DDList and it basically does the same thing (retrieving each record, parsing it and adding the value to the DDList) but you cannot do that in a SOAP call as the XML needs to be interpretted 1st (the binding cannot introspect into the XML to understand its structure).

Hope that helps

Paul