0

Most probably it is a duplicate question but none of existing question doesn't solve my problem.

I have a form called client. In that form I have a combobox for choosing country. But if user's country is not available they can add their country. SO when they choose add new from combobox one fxml file will popup and ask them to enter country name.

When they click add country button I want two things to be happened. first: new country will be saved to DB second: country combobox's value will be updated with new country name.

Note: add Country form has different controller.

Please help. TIA

K.M.S
  • 91
  • 2
  • 8
  • Just pass the `ComboBox`'s items list to the new controller, then it can add the new country to the list. – James_D Feb 06 '18 at 18:56
  • How can I? AddClientController where I want to send new value from controller AddController where AddCountry form located. – K.M.S Feb 06 '18 at 19:03
  • You're loading that FXML from the `AddClientController`, right? The `AddClientController` has access to the combo box, so it can call `getItems()` and pass that list directly to the controller for `AddCountry`. If it's not working, edit your question to show your attempt to do that. – James_D Feb 06 '18 at 19:10
  • Another way to do it is to define a method in the controller for the "Add country" form that returns the country that was added. Then if you use `showAndWait()` on the stage showing the "add country" form, you can call that method afterwards and do whatever you need with the added country. – James_D Feb 06 '18 at 19:13

0 Answers0