Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello,
In my ACL script, I need to create a dialog box to include multiple check boxes so users can select either one or more items from it. Unfortunately I wouldn't be able to know those items ahead of time. I'll have to open a SGML/XML file and collect all the possible selections, then create multiple check boxes for it. Because of that, I went back to Arbortext online help to see if any other alternatives could fit my needs. So the list_response() command was found. But it seems to support single-selection list box only, not multiple-selection one. Could anyone help me on it?
Sincerely,
Jing
Hi Jing--
If there will only a few items in your list, you might be able to get by with a readvar command, something like this:
function test() {
local foo, bar, baz;
# for readvar, the -choice option with only one choice gives a checkbox
readvar -prompt "Choose" -choice "foo" foo -choice "bar" bar -choice "baz" baz;
# checked items will return 1, unchecked will return 0
response("foo: $foo; bar: $bar; baz: $baz");
}
The readvar command above will display a dialog like this:
Of course, in your case you would need to construct the "readvar" command string dynamically based on what you find in your document. If it's a long list, the command might end up being too long, or your list might make a dialog too big to fit on the screen.
In that case, you will probably need to resort to making a simple XUI dialog, for example with a combobox, where the listitems in the combobox are dynamically generated using ACL code. (Comboboxes can be configured to be multi-select, where users choose multiple entries by ctrl-clicking.) You could also make a XUI dialog that is basically empty, and have your ACL code dynamically add separate checkboxes for each of the choices you found in the document.
--Clay
Hello Clay,
Thank you very much for your prompt help!
In my other ACL script, I used XUI dialog box for the items that had been determined ahead of time. But for the dynamic items (e.g. file #1 could have "A", "B", and "C" items and file #2 could have "D", and "E"), it seems to be a little challenging! That's why I'd like to find other alternatives. BTW, I always used readvar() for radio button, and didn't realize that it could be used for check box too! Thanks again for the tip you sent to me. I really appreciate it.
Best,
Jing
Hello Clay,
I'd like to do one of your suggestions--create an empty XUI dialog box and have my ACL code dynamically add checkboxes in for the ones found in the documents. Each document may have different choices.
Below is what I had done before for a predetermined checkboxes & radio buttons in a XUI dialog box.
--Create a XML file and add in all the checkboxes, radio buttons, and embedded javascript code.
--Create a XUI dialog box in my ACL script and open the XML file.
--The embedded javascript code in XML would get all the checked boxes and/or buttons in the dialog box when clicked.
--Pass the checked boxes/buttons information back to my ACL script to process further by calling dlgitem* functions.
The help I'd like to get is on how to dynamically add checkboxes in. In the XML file I created before, I had the following code for checkboxes. But those are predetermined ones. How do I do it if it's not predetermined?
<groupbox label=....><gird columns=...>
<checkbox id...></checkbox><checkbox id...></checkbox></grid><groupbox>
Sincerely,
Jing
Hi Jing,
As Clay mentioned, you will need to add the checkbox items dynamically. The XUI dialog that Editor displays is based on XML that it reads in as a document, which means you can access that document and modify the DOM. Anything you modify will be reflected in the displayed document. In your case, I think the best bet is to do the following:
Hi Brian,
I'll follow your suggestion to see how far I can reach. Thank you very much for your prompt help! I really appreciate it.
Jing
Hi Jing--
You can do this in all ACL if you prefer. There is a set of dialog functions, most of which start with dlgitem_* for interacting with dialogs using ACL. This includes adding new controls or listitems, and reading results.
Here is a simple example that uses all ACL to dynamically build a dialog listing all the titles in the current document, and letting the user select one or more of them. Note the use of dlgitem_add_callback() to attach behavior to the OK button, which avoids the need to insert javascript code in the XUI document itself. (If you prefer Javascript, it will also work perfectly well to put it in the XUI markup, just as you might with a static dialog.)
--Clay
function showdlg() {
# create new dialog document
local dlgoid = _xmldlg::newDialog("titledlg","Choose titles");
# add listbox and OK button
insert("<listbox id='titlelist' type='multiple'><listitem id='id_foo'>foo</listitem></listbox><button id='okbtn' type='OK' label='OK'/>", oid_doc(dlgoid));
local dlgwin = _xmldlg::newWindow(dlgoid);
# get all titles from current document and store content in titletext[] array
local titles[],t;
xpath_nodeset(titles,"//title");
local titletext[];
for (t = 1; t <= count(titles); t++) {
titletext[t] = oid_content(titles[t]);
}
# set the listbox to include the titles
dlgitem_set_list_array(dlgwin, 'titlelist', titletext);
# attach the callback to the OK button
dlgitem_add_callback(dlgwin, 'okbtn', 'okbtncallback');
# everything is ready, show the dialog
window_show(dlgwin,1);
}
function okbtncallback(windowid, dlgitem, eventtype, eventsubtype, detail) {
if (eventtype == "ITEM_CHANGED") {
local selected[];
local labels[];
# get all titles in list
dlgitem_get_list_array(windowid, "titlelist", labels);
# get selected title indexes
dlgitem_get_select_array(windowid, "titlelist", selected);
local msg = "You picked:\n\n";
# for each selected title, use the index to look up the listitem text
for (s in selected) {
msg .= " " . labels[selected[s]] . "\n";
}
# do something useful with selected items here
response(msg);
}
}
showdlg();
Hello Clay,
I'm deeply grateful for both of your answers. Since I'm new to XUI, the examples you provided are definitely very helpful! I'll take a closer look at the code to learn the ideas from it.
Thank you very much for spending your precious time to help me. I really appreciate it and won't take it for granted.
Sincerely,
Jing
Hello,
I got "ITEM_FOCUSED" instead of "ITEM_CHANGED" event in my callback function. Within the code, there are one multiple selected list box on the top followed by 2 radio buttons, and both OK and Cancel buttons at the bottom. My ACL tool is executed by clicking a menu item in a XML document. The "ITEM_FOCUSED" event is generated right after I select multiple items from the list box, two radio buttons, and clicked OK in the popup XUI dialog box. Did I miss anything so I didn't get "ITEM_CHANGED" event?
Sincerely,
Jing