Customizer's Guide > Working with XUI (XML-based User Interface) Dialog Boxes > Embedding XUI Dialog Box Controls in a Document
  
Embedding XUI Dialog Box Controls in a Document
You can embed XUI dialog box controls in the content of a document displayed in Arbortext Editor. Users can use these controls to interact with other data sources, take advantage of ActiveX controls, select values from restricted lists, and so on.
Use the following steps to embed XUI dialog box controls in a document. (Examples follow.)
1. Create a XUI file defining the dialog box controls you want embedded in the document. Use events in <script> elements to define the actions to occur when the events are triggered.
2. Determine which element in your DTD you want to replace with the contents of the XUI file defining the dialog box controls.
3. Add a <XuiControl> element to the <Specials> section of the DTD's .dcf file specifying the element in the DTD you want to replace with the contents of the XUI file.
The <XuiControl> element has the following attributes:
element — The name of the element to be associated with an embedded XUI control.
xuiFileName — The file that describes the XUI dialog box controls.
condition — An XPath expression specifying whether to create the dialog box controls based on one or more attributes or values. If the expression evaluates to TRUE, the controls will be created or attached to. If the expression evaluates to FALSE, the controls will not be used.
4. Create a new document based on the DTD and insert the chosen element.
The XUI controls appear in the Edit pane embedded in the flow of the document. The Document Map shows the element with an icon signifying it as embedded XUI markup. Hover the mouse pointer over the icon to display the name of the XUI file referenced by the element.
By default, the XUI controls are displayed embedded in the document. You can display the XUI markup inline instead of the rendered controls using the ACL set command set dialogdisplay=off. set dialogdisplay=on will again display the embedded controls.
When using embedded XUI dialog box controls, be aware that only one occurrence of a specific element's dialog box can be displayed at one time. If the same element appears in multiple open windows, only one occurrence of the element will be displayed as an embedded XUI control.
Example 11. Embedded combo box
This example shows how to embed a combo box in a document. The user can select an item from the combo box and have it inserted at the current cursor location.
1. Create a XUI file defining the combo box. In the following example, the script element causes the chosen value to be inserted at the current cursor location. The XUI file is saved as units.xml.
<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2003, v.4002-->
<!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.1//EN"
"xui.dtd">
<window orient="vertical"
modal="false"
title="UnitSelection">
<label label="Select a unit of measure:"/>
<combobox value="grams" type="dropdown">
<listitem label="grams"/>
<listitem label="kilograms"/>
<listitem label="milligrams"/>
<listitem label="ounces (Troy)"/>
<listitem label="ounces (U.S.)"/>
<listitem label="pounds (Troy)"/>
<listitem label="pounds (U.S.)"/>
<script type="application/x-javascript" ev:event="domactivate">
var selection = Application.event.target.getAttribute("value");
var textnode = Application.activeDocument.createTextNode(selection);
Application.event.view.window.ownerNode.appendChild(textnode);
</script>
</combobox>
</window>
2. For purposes of this example, the action element is defined in the .dcf file as the element to be replaced with the dialog box generated by units.xml:
<Specials>
<XuiControl element="action" xuiFileName="units.xml"/>
3. Embed the combo box in the document by inserting the action element. For example, the source XML:
<book>
<title>Units of Measure Example</title>
<chapter>
<title>Example:</title>
<para><action></action></para>
</chapter>
</book>
appears in Arbortext Editor as follows:
Selecting an item from the combo box will insert the contents of the <combobox>value element at the current cursor location.