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.

Dynamically populating a caption

Avatar

Former Community Member
I have an example of how to bind field captions to a data source (e.g. an XML data file).



Now, I am investigating how to change the language of field captions at runtime with the press of a button (i.e. by dynamically changing the data source).



I already have an example of how to do this using embedded data, but I would like an example of this using external data sources and I would like the data sources to be XML files.



Has anyone got any expertise in this area? ..I'd appreciate your input.



Thanks.
1 Reply

Avatar

Former Community Member
I have the following task (LiveCycle Designer 7.1):<br />A form has a drop down list with the language selection.<br />Based on the user selection the captions of all the fields on the form should change.<br /><br />I have created a hidden text field and pasted am xml file there.<br /><captions><br /> <languages><br /> <language><br /> <token>US</token><br /> <text>English(US)</text><br /> </language><br /> <language><br /> <token>GR</token><br /> <text>German</text><br /> </language><br /> </languages><br /> <US><br /> <caption><br /> <token>cust_no</token><br /> <text>Customer Number:</text><br /> </caption ><br /> <caption><br /> <token>cust_name</token><br /> <text>Found customer:</text><br /> </caption ><br /> </US><br /> <GR><br /> <caption><br /> <token>cust_no</token><br /> <text>Kunden-Nr:</text><br /> </caption ><br /> <caption><br /> <token>cust_name</token><br /> <text>Gefundener Kunde:</text><br /> </caption ><br /> </GR><br /></captions><br /><br />On form init event I call loadXML function to load the xml file into memory<br /><br />I have the following script to change the caption (placed in drop down change event):<br /><br />var tempString = this.boundItem(xfa.event.newText); // takes a token value from the dropdown<br /> var objDataGroup = xfa.resolveNode("$data.captions." + tempString);<br /> if(objDataGroup != null) {<br /> for (var i=0; i < objDataGroup.nodes.length; i++) { <br /> var captionNode=objDataGroup.nodes.item(i);<br /> if (captionNode != null ) { <br /> var tokenNode=captionNode.nodes.item(0);<br /> var textNode = captionNode.nodes.item(1); <br /> var nodeString = "xfa.form.form1.Body." + tokenNode.value +".caption.value.text";<br /> var node = xfa.resolveNode(nodeString); <br /> if (node != null) {<br /> node.value = textNode.value;<br /> }<br /> }<br /> } <br />}<br /><br />This code does not change the captions at all!<br />What is wrong with it?