How to use a file picker from an XUI dialog?

Answered by: Clay Helberg Last Updated: 2006-10-25 =Question by N.N.==

I'm a complete novice at both ACL and XUI, but I'm trying to learn. One of the things I'm trying to learn is how to create my own file picker dialog. I'd like to create a dialog box with a button that allows the user to select a file using a standard file picker.

I have created a dialog box in XUI (XUI is cool!), but I can't find a file picker for XUI. I found one in ACL, though - file_selector. Can I call an ACL function from a XUI button?

=Clay Helberg answers=

You can use the Acl.eval javascript function to do this. Here's an example from one of our custom dialogs:

  // Show file dialog and get result filename = Acl.eval("file_selector('.','xml','XML files|*.xml|All files|*.*','Select Document')"); if (filename != null) { dlgdoc = Application.event.target.ownerDocument; href = dlgdoc.getElementById("href").firstChild; if (href.firstChild != null) href.removeChild(href.firstChild); text = dlgdoc.createTextNode(filename); href.appendChild(text); }

The script pops up the dialog, and the user can select a file. (If the user cancels, the function returns null.) Then the script populates the associated text box (with id = "href") with the value selected.