Scenario:
I have a parent window called EditClientDeatils.fxml and have a TableView on this. I am editing these row result by creating another window named UserDetails.fxml and populating the row data to this FXML fields, now after editing from my second window , If I save I need to update the parent table with latest data.I tried something like below and not refreshing the table at all. But when I debugged my table list is updated with latest Data and not showing that in Window.
So How can I update my table view from different controller ?
In Child Window I am loading the parent like this.
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("EditClientDetails.fxml"));
EditClientDetailsController fooController = (EditClientDetailsController) fxmlLoader.getController();
try {
fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(NewUserController.class.getName()).log(Level.SEVERE, null, ex);
}
And in my parent class initialize method having below code:
@Override public void initialize(URL url, ResourceBundle rb) {
fNameCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("clientFirstName"));
lNameCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("clientLastName"));
addressCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("clientAddress"));
mobileCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("clientMobileNumber"));
emailCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("clientEmailID"));
catagoryCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("clientTypeCode"));
genderCol.setCellValueFactory(
new PropertyValueFactory<AtUser, String>("gender"));
editSaveAction.setSortable(false);
editSaveAction.setCellValueFactory(
new Callback<TableColumn.CellDataFeatures<AtUser, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<AtUser, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
editSaveAction.setCellFactory(
new Callback<TableColumn<AtUser, Boolean>, TableCell<AtUser, Boolean>>() {
@Override
public TableCell<AtUser, Boolean> call(TableColumn<AtUser, Boolean> p) {
return new ClientButtonCell(customerTable);
}
});
// Add filtered data to the table
customerTable.setItems(filteredData);
// Listen for text changes in the filter text field
filterField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
updateFilteredData();
}
});
}
When I am debugging
customerTable.setItems(filteredData);
this filteredData is containing my required data but not coming on Window.
please point out if I missed anything.