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.

Binding a ListBox to XML

Avatar

Level 7

How can I bind a listbox to a schema? What should the structure look like? The list box will have multiple selections.

Aditya

6 Replies

Avatar

Level 10

Hi Aditya,

I've used a schema element like;

<xs:element name="multiSelectListBox">
<xs:complexType>
  <xs:sequence>
   <xs:element name="value" type="xs:int" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>
</xs:element>

The trick I found was in the binding, if you use designer you will get a binding expression like;

$.multiSelectListBox.value[*]

But what I needed to do was manually remove the ".value[*]" so my binding expression was;

$.multiSelectListBox

So I think you have to use a repeating schema element named "value" for it to work, but that fits in with my naming style so have not played with that.

Good luck

Bruce

Avatar

Level 7

It worked!

How did you figure this out? Thank you for helping.

Aditya

Avatar

Level 10

Took a good bit of 'randon programming', though it does kind of make sense, I would call this is a bug in Designer.

Anyway glad to hear it worked.

Bruce

Avatar

Level 7

I have one more hurdle... In the process, I am using to merge that XML with another form and the element will be bound to a textfield.

Below are the binding scenarios I tried...

1) $record.element.value[*] - This only gave the first value

2) $record.element - I get a binding error

I am thinking, the only way will be to get the values from the XML programmatically.

Thanks!

Aditya

Avatar

Level 10

Hi Aditya,

I don't think you will have much luck binding a nodelist to a textbox.  You could try going into the XML Source and finding "element" under under the <dd:dataDescription> node, it should have an attribute xfa:dataNode="dataGroup" which you could change to xfa:dataNode="dataValue".  As long as there is no other xfa:dataNode="dataGroup" under the "element" one, that will fix your binding error  you are getting with the second approach you tried, might not look that pretty though.

I assume this is for display only? So I would probably go with some scripting.  You could also look at using XSLT and I did post a very simple example of using XSLT in the Cookbooks, http://cookbooks.adobe.com/post_Numbering_rows_in_a_LiveCycle_Designer_table_or_re-18443.html, which might get you started.

Good luck.

Bruce