I have started using JavaFX for a few weeks. Here is a code snap of a TableView
@FXML protected void handleSubmitButtonAction(ActionEvent event) {
log.debug("handleSubmitButtonAction");
service.save(new InputText(inputText.getText()));
List<OutputData> outputDataList = new ArrayList<>();
service.getAll().forEach(e -> outputDataList.add(new OutputData(e)));
ObservableList<OutputData> list = FXCollections.observableArrayList(outputDataList);
outputView.setItems(list);
inputText.setText("");
}
What it does is that
- Create a new entry
- Save it to DB
- Fetch all entries from DB
- Create TableView row data for each entry
- Create an ObservableList with all of the row data
- Add the list to the TableView
That certainly isn't effective. Is a way to add a newly created entry directly to the TableView?