I want to show a custom JavaFX 8 dialog to a user, capture data from the user and then close the dialog after the data is saved to the database (or shows an error message\alert).
At the moment, the dialog is shown with the following code:
Optional<MyType> result = dialog.showAndWait();
Followed by code:
myrepository.save(result)
From reading the documentation, it looks like instead I should perform this repository.save in a background Task?
It looks like this code could only be executed after showAndWait();
and couldn't close the standard dialog as this would need to be done on the JavaFX application thread?
Is there a way to only show the dialog, save the data, and then show a confirmation dialog only if the database save succeeds on the background Task?