Error calling controller.getWindow().hide()

Questions, tips and tricks and techniques for scripting in Servoy

Error calling controller.getWindow().hide()

Postby LXS » Tue Dec 16, 2014 12:39 pm

Hi,

when i want to close a form in dialog i use the following code to do that:

Code: Select all
controller.getWindow().hide()


But sometimes - not always - i get this error message:

Code: Select all
TypeError: Cannot call method "hide" of null


It seems that
Code: Select all
controller.getWindow()
does not return a Window all the time.

Is it better to use
Code: Select all
application.getWindow().hide()
?

If yes, what is the difference between this methods?

Thanks,
Alex
Alexander Stefan
Dr. Maison & Partner GmbH
www.servoy-plugins.de
www.maison-partner.de
LXS
 
Posts: 101
Joined: Thu Mar 01, 2007 12:00 am

Re: Error calling controller.getWindow().hide()

Postby LXS » Thu Dec 18, 2014 10:32 am

I can't believe, that nobody closes forms in dialog :D
Alexander Stefan
Dr. Maison & Partner GmbH
www.servoy-plugins.de
www.maison-partner.de
LXS
 
Posts: 101
Joined: Thu Mar 01, 2007 12:00 am

Re: Error calling controller.getWindow().hide()

Postby Peter de Groot » Thu Dec 18, 2014 10:57 am

Hi,

I always use a closeWindow() method, somthing like:

Code: Select all
function closeWindow($event){
       application.getWindow($event.getFormName()).hide();
}


Never any problems hiding/destroying dialogs.

Regards,

Peter
Servoy 7.3.x || 7.4.x

NEM ENERGY BV
Peter de Groot
 
Posts: 207
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Error calling controller.getWindow().hide()

Postby LXS » Thu Dec 18, 2014 10:59 am

Thanks for your reply Peter, but you use application.getWindow() and not controller.getWindow() - right?
Alexander Stefan
Dr. Maison & Partner GmbH
www.servoy-plugins.de
www.maison-partner.de
LXS
 
Posts: 101
Joined: Thu Mar 01, 2007 12:00 am

Re: Error calling controller.getWindow().hide()

Postby Peter de Groot » Thu Dec 18, 2014 11:03 am

LXS wrote:Thanks for your reply Peter, but you use application.getWindow() and not controller.getWindow() - right?


Yes, that's right, the event passes the form name.

Regards,

Peter
Servoy 7.3.x || 7.4.x

NEM ENERGY BV
Peter de Groot
 
Posts: 207
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Error calling controller.getWindow().hide()

Postby jcompagner » Mon Dec 22, 2014 11:37 am

if controller.getWindow() doesn't return a window, then that form where that controller belongs to is not in a visible window anymore. (so the window is already hidden or destroyed)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7977
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 2 guests