I am having trouble getting a window to close. Here is the code I use to create and show my window:
// create a modal dialog
md = application.createWindow("chartsList", JSWindow.MODAL_DIALOG);
md.title = "Charts for " + activepatient_to_encounters.name_lfm;
//Pass Window Name
globals.g_WindowName = md.getName();
//load form in window
forms.Encounters_Charts.controller.show(md);
I copied the sample code for application.getWindow() to get me started:
// close and dispose window resources
win = application.getWindow("someWindowName");
if (win != null) {
if (win.isVisible()) win.close();
win.destroy();
}
Here is my close method:
//Declare Variables
var win;
// close and dispose window resources
win = application.getWindow(globals.g_WindowName);
if (win != null)
{
if (win.isVisible())
{
win.close();
// win.destroy();
}
globals.g_WindowName = null;
}
If I leave in win.destroy(), my window closes. If I comment it out and just use win.close(), my window doesn’t close. In debugger I notice that my variable ‘win’ is set to the following:
com.servoy.j2db.scripting.JSWindowImpl$JSWindow@127ab93 {title:"Charts for Test Patient"}
which is the title of my created window, not the name. Therefore win.close() won’t work. Am I doing something wrong?