Closing solution window programatically

Forum to discuss the Web client version of Servoy.

Closing solution window programatically

Postby mmgomez » Mon May 24, 2010 6:50 pm

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
Code: Select all
<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 http://code.google.com/p/web-client-utils/ plugin from Sean Devlin to do this
Code: Select all
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:
Code: Select all
function dialogClose()
{
   application.closeForm();
   forms.frmMain.ExitSolution();
}


Code: Select all
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.
Code: Select all
   application.closeSolution(null,plugins.WebClientUtils.executeClientSideJS('window.close()'),null)


any tips?

Thanks in advance.
Martin
If debugging is the process of removing bugs, then programming must be the process of putting them in. -Dijkstra.
mmgomez
 
Posts: 7
Joined: Wed Sep 30, 2009 10:43 pm

Re: Closing solution window programatically

Postby lvostinar » Tue May 25, 2010 10:24 am

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()
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Closing solution window programatically

Postby mmgomez » Tue May 25, 2010 7:45 pm

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
If debugging is the process of removing bugs, then programming must be the process of putting them in. -Dijkstra.
mmgomez
 
Posts: 7
Joined: Wed Sep 30, 2009 10:43 pm

Re: Closing solution window programatically

Postby lvostinar » Wed May 26, 2010 9:56 am

mmgomez wrote: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).
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Closing solution window programatically

Postby mmgomez » Thu May 27, 2010 11:31 am

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.
If debugging is the process of removing bugs, then programming must be the process of putting them in. -Dijkstra.
mmgomez
 
Posts: 7
Joined: Wed Sep 30, 2009 10:43 pm


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 17 guests

cron