Autoupdating rows in TableView from model

to make TableView able to track data changes you need to expose relevant fields as JavaFX properties. Add next methods to Person class from tutorial:

    public SimpleStringProperty firstNameProperty() {
        return firstName;
    }

    public SimpleStringProperty lastNameProperty() {
        return lastName;
    }

    public SimpleStringProperty emailProperty() {
        return email;
    }

There is a bug in TableView update (https://javafx-jira.kenai.com/browse/RT-22463). I had similar problem and after some search this is my workaround. I found that if the columns are removed and then re-added the table is updated.

public static <T,U> void refreshTableView(TableView<T> tableView, List<TableColumn<T,U>> columns, List<T> rows) {        
    tableView.getColumns().clear();
    tableView.getColumns().addAll(columns);

    ObservableList<T> list = FXCollections.observableArrayList(rows);
    tableView.setItems(list);
}


Example of usage:

refreshTableView(myTableView, Arrays.asList(col1, col2, col3), rows);