Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Use SubForm Set for a choice in XML Schema

Avatar

Former Community Member
I have questions on subformset, the parameter to the 'setInstances' method and the use of 'intial' attribute of 'occur' element of XFA. <br /><br />In XML schema, sometimes there are exclusive choice. In my example, user has to choose between a customer number and postal-address (name, address, city, state...). I use a check box in the form, so either the customer number or postal address subform can be shown, but not both at the same time. I have no problem displaying them on the form. The problem is when I export the XML data from it. It does not work after user clicks on the check box once. If I use button instead of check box, user can press the button no more than twice. Then only the data of the first element in posta-address are exported.<br /><br />I use setInstances(1) and setInstance(0), but I could not find any documentation on the description of the parameter of setInstances.<br />Anyone can take a look at it and help?<br /><br />Thanks. <br /><br />Hongwei Li<br /><br />I would like to post the XDP file. But it is too long (1000 lines) to fit here. So I post javascript and the XML Schema.<br />==========================================================================<br /><event activity="change"><br /> <script contentType="application/x-javascript">if(this.rawValue==true){<br /><br />_customerNumber.setInstances(1);<br />_correspondenceAddress.setInstances(0);<br />}<br />else{<br /><br />_customerNumber.setInstances(0);<br />_correspondenceAddress.setInstances(1);<br />}</script> <br /><br /> <br /><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="XFASchemaXSD3"><br /> <xsd:element name="us-correspondence-address"><br /> <xsd:complexType><br /> <xsd:choice><br /> <xsd:sequence><br /> <xsd:element ref="name-1"/><br /> <xsd:element ref="name-2" minOccurs="0"/><br /> <xsd:element ref="us-postal-address"/><br /> </xsd:sequence><br /> <xsd:element ref="customer-number"/><br /> </xsd:choice><br /> </xsd:complexType><br /> </xsd:element><br /> <xsd:element name="name-1" type="xsd:string"/><br /> <xsd:element name="name-2" type="xsd:string"/><br /> <xsd:element name="us-postal-address"><br /> <xsd:complexType><br /> <xsd:sequence><br /> <xsd:element ref="address-1"/><br /> <xsd:element ref="address-2" minOccurs="0"/><br /> <xsd:element ref="city"/><br /> <xsd:element ref="state" minOccurs="0"/><br /> <xsd:element ref="postcode" minOccurs="0"/><br /> <xsd:element ref="country"/><br /> <xsd:element ref="email" minOccurs="0" maxOccurs="unbounded"/><br /> <xsd:element ref="phone" minOccurs="0" maxOccurs="unbounded"/><br /> <xsd:element ref="fax" minOccurs="0" maxOccurs="unbounded"/><br /> </xsd:sequence><br /> </xsd:complexType><br /> </xsd:element><br /> <xsd:element name="customer-number" type="xsd:string"/><br /> <xsd:element name="address-1" type="xsd:string"/><br /> <xsd:element name="address-2" type="xsd:string"/><br /> <xsd:element name="city" type="xsd:string"/><br /> <xsd:element name="state" type="xsd:string"/><br /> <xsd:element name="postcode" type="xsd:string"/><br /> <xsd:element name="country" type="xsd:string"/><br /> <xsd:element name="email" type="xsd:string"/><br /> <xsd:element name="phone" type="xsd:string"/><br /> <xsd:element name="fax" type="xsd:string"/><br /></xsd:schema>
14 Replies

Avatar

Former Community Member
Hongwei,



Regarding to the document, you can find it
here



Also, you can find an example of this method in Designer help. Search for keyword "Creating a button to add and remove a section" .



The SetInstance() method used to add or remove instances of an XFASubform or XFASubformSet child of this XFAForm node.

The parameter is an integer which is the number of instances of the xfa subform or subform set's child that you want to add or remove.



You can find an example of this method in the "dynamic purchase order" example that comes with Designer. The javacript is on the "Add Comments" button.

Avatar

Former Community Member
Jimmy,



Thanks for you reply.



I have read the document you referred to. It is for Designer 6.0. There is no setInstances() method in that version.



My situation is different than the purchase order because I have a schema behind it and user has to choose between the two subforms in a subform set. In the sample. It just hides a section.



Hongwei

Avatar

Former Community Member
Hongwei,



I just create an example for you to see how you can display a certain subform based on the checkbox being checked or not.

This example is rather simple. Once you know how it works, you can add more form fields from your data schema.



In this example, there is a hidden button that has the following javascript on "click" event. I also introduce a form variable called "fComments" to use as a flag.



if (fComments.value == "0") {



_member.setInstances(1);

_nonMember.setInstances(0);

fComments.value = "1";

}



else {

_nonMember.setInstances(1);

_member.setInstances(0);

fComments.value = "0";

}




Here is the example.

Avatar

Former Community Member
Jimmy,



Thanks for creating the sample. I really appreciate it. I sent my sample to you before. In the sample you created. You don't have a schema behind it. Once you connect your sample to a schema. It has the same behaviour as mine. It stops working after click the check box twice.



I will send you another email, I embed the a schema in the sample you created. Take a look at the data exported and you will see the problem.



Again, Thanks a lot.



Hongwei Li

Avatar

Former Community Member
Hongwei,



I looked at your form that has a data schema attached to it.

As far as the issue with the flow content subform, it works fine for me no matter how many times I click on the checkbox.



The only issue that I found is when you export the data, it returns nothing.

I believe you have to design your form hierarchy so that it looks similar to your data schema in order for the form to return the data when you submit.

Avatar

Former Community Member
Here is an example that works with your XML schema attached to the form.



Basically, what I did was:



- From the "data view" pallete, I drag the "order group" node onto the body page.

- I then removed fields that I don't need from the body page.

- I begin to wrap group of form controls in subforms.

- I set all appropriate properties for the subforms.

- I add a "Submit by Email" button to each subform.

- I add a form variable "fComments" and set it to 0.

- I then attach javascript to the checkbox and the hidden button.

- Save it as dynamic pdf and test it.

Avatar

Former Community Member
Jimmy,

Could you please post the url of this new PDF? thanks.



Hongwei

Avatar

Former Community Member
Hongwei,

The link is in my previous post. Click on the first word "Here".

Avatar

Former Community Member
Jimmy,



Sorry about the negligence. Thanks a lot!



This time I can not even export the data of member number for once. Actually I tried different hierarchies (the default by designer is using subformset and useoneof, I have to make changes in XDP to mark both of the min attribute to '0' and one of the branch intitial attribute of occur element to '1'). I had no no luck.



I think this is an Acrobat 7.0 bug. Or in another word, Acrobat 7.0 is not ready to handle XML schema when the content model is more complex. I will have to wait until we go documentation on setInstances() method. I guess the reason of the bug (if it is) is because when you do the setInstances(0), the branch of data DOM was set to NULLType and could not recover back when you click the checkbox to reactivate this portion again.



Hongwei li

Avatar

Former Community Member
Can you email me your latest form development with the issues that you mentioned in your last post?

Avatar

Former Community Member
I was talking about the form (hongwei.pdf) you recently posted and the samples I sent you before. When Exporting data or submit the data XML, They all have the sampe problem. Actually I sent email to ADOBE to see if you can take a look at it. I haven't heard anything back.



Thanks.



Hongwei

Avatar

Former Community Member
Hongwei,



Apparently, the sequence in which the setInstances() method is called does have an effect on the dataset.



You can take a look at the Hongwei.pdf again to see what was changed.

Avatar

Former Community Member
Hi,



I was trying to look at this sample as I have a number of choices in my XML schema that I wanted to control the display of the sub-forms via radio buttons. However, I can't access http://66.34.186.88/LiveCycleSamples/HongWei.pdf. Is there any way of posting this elsewhere or emailing it to me?



Thanks!

Michael