Why is the XUI document not closed after the dialog closes?

Last Updated: 2006-06-18

This mystery by Daniel Riggs still unsolved? or did the suggestion by Lynn Hales solve it?

=Daniel Riggs=

Take a XUI file which looks like this:

 <!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.0//EN" "xui.dtd" [ ]> <?Pub Caret?>

And some java code like this:

public class XuiTest {       public static void main(String[] args) {               Document xuiDoc = Application.openDocument("C:/xui.xml"); Dialog form = Application.createDialogFromDocument(xuiDoc); NodeList listboxes = xuiDoc.getElementsByTagName("listbox"); Element listItem = xuiDoc.createElement("listitem"); listItem.setAttribute("label","testvalue"); listboxes.item(0).appendChild(listItem); form.show; } }

And call with the line:

local $object = java_constructor("XuiTest");

Now, the first time this is run, everything works perfectly... however, if you close the form and then run the code again - disaster! Now we have two test values in our list - nooooo! Even though it is creating a new object each time which does the openDocument call, it seems that Epic seems to keep the (xui.xml) document in memory after the object reference is lost (makes no difference if you use java_delete($object) here).

Why is the document not closed after the dialog closes? And does anyone have a workaround or suggestion as to how I can resetting the Xui document for this to work?

=Lynn Hales=

Take a look at the window_list (help 208) and see if the XUI file is still open. If it is you may need to add some code to explicitly kill the window (window_destroy(help 202) or maybe window_close(help 198)) and clear the list each time the script is run.

I am sure that one of the many Java programmers out there can answer this, but Epic likes to keep scripts it has loaded resident in memory. Epic can also 'hide' files from view so they are available later.