Closing solution window programatically

Hi,
I’m facing a problem in the development of my web application:
First, I load the solution in a popup window from the main website using

<a href="http://localhost:8080/servoy-webclient/solutions/solution/mySolution" target="_blank" onClick="window.open(this.href, this.target, 'menubar=0,location=0,toolbar=0,status=0,width=900,height=600'); return false;">

I need to close the popup window when the user finishes or cancels the process.
I’m using the wonderful WebClientUtils Google Code Archive - Long-term storage for Google Code Project Hosting. plugin from Sean Devlin to do this

plugins.WebClientUtils.executeClientSideJS('window.close()');

that works OK for the main form, but when I use the same method from a modal dialog, it doesn’t close the solution window.
I’ve tried to do this:

function dialogClose()
{
	application.closeForm(); 
	forms.frmMain.ExitSolution();
}
function ExitSolution()
{
	application.closeFormDialog(true);
	plugins.WebClientUtils.executeClientSideJS('window.close()')
}

but the results are the same. application.closeSolution doesn’t do what i want either.

	application.closeSolution(null,plugins.WebClientUtils.executeClientSideJS('window.close()'),null)

any tips?

Thanks in advance.
Martin

In which window is the javascript code executed ? You can use self.close() to close window from itself; but I guess the javascript is executed in main window so this is why the popup is not closed. If that is true, you need a reference to the window to close it from main window like: var mypopup = window.open… ; mypopup.close()

Thanks for your response Laurian,
I have only one “main” form (the one that goes into the popup called from the site HTML) and 2 small forms that show error messages or process information. Both of them are invoked with application.showFormInDialog(), with modal=true.

If i close the solution from the main form, it closes the popup.
If i close the solution from one of the modal FID, it stays open.

I think the quick fix for this behavior will be to “flatten” the solution and not using FID anymore, but it means some serious rewrite and really like to avoid that.

Regards,
Martín

BTW: I’m using Servoy 4.1.7

mmgomez:
Thanks for your response Laurian,
I have only one “main” form (the one that goes into the popup called from the site HTML) and 2 small forms that show error messages or process information. Both of them are invoked with application.showFormInDialog(), with modal=true.

If i close the solution from the main form, it closes the popup.
If i close the solution from one of the modal FID, it stays open.

I think the quick fix for this behavior will be to “flatten” the solution and not using FID anymore, but it means some serious rewrite and really like to avoid that.

Regards,
Martín

BTW: I’m using Servoy 4.1.7

Ok, so you try to close the main form and the two modal dialogs from javascript event ? You can close the two modals with application.closeFormDialog(true);. About the main form it is a bit more complicated. If you execute javascript in main form window.close() will work. If you execute javascript in one of the modal popups window.close() will not work because window is not a reference to main window (in that context). You can try window.parent.close() ; I think this way you reference the main window (in this situation).

Thank you Laurian, it works flawlessly :D

I was confused because the javascript code was in the main form, but i was calling it from the modal one.