Error calling controller.getWindow().hide()

Hi,

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

controller.getWindow().hide()

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

TypeError: Cannot call method "hide" of null

It seems that ```
controller.getWindow()


Is it better to use ```
application.getWindow().hide()
```?

If yes, what is the difference between this methods?

Thanks,
Alex

I can’t believe, that nobody closes forms in dialog :D

Hi,

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

function closeWindow($event){
       application.getWindow($event.getFormName()).hide();
}

Never any problems hiding/destroying dialogs.

Regards,

Peter

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

LXS:
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

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)