-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OnViewRemoved method is not invoked on Window closed #591
Comments
The I managed to get it working with this code: stage.setOnCloseRequest(windowEvent -> {
stage.getScene().setRoot(new VBox());
}); This explicitly changes the root-node of the scene so that the old root-node (your Window view) is removed from the scene. Maybe it's a good idea to wrap the |
Thanks for your answer. |
No, your code also works fine. The advantage of your code is that you don't depend on strange behavior of JavaFX (like not resetting the scene). The disadvantage is that your ViewModel has to explicitly provide the stop method and you have to invoke this method manually in your app class which introduces a dependency form the app class to this specific viewModel. Other then that I don't see any disadvantages in your code. Both solutions are trade-offs. |
When i open new Window from my "Main Application Window" after closing new Window method onViewRemoved in my ViewModel is not invoked.
I use also SpringBoot in my project and i try using @PreDetroy on both @component scopes (prototype and singleton) - won't help. @PreDestroy is only invoked for singleton components and after whole application is closed but i want to listen for event when one of the windows in my application is closed.
This is the code that opens new window
I got ViewModel for TestView it looks like this:
After closing new Window based on TestView method onViewRemoved on TestViewModel is not invoked. It's pretty important for me to actually make it work.
I figure out that i can set on stage listener on close request like that:
I manage to make that work in that way:
is this the best way for doing this? onViewRemoved won't be invoked?
Do you have anny suggestions?
The text was updated successfully, but these errors were encountered: