0

I need to decouple the data reading from database process from database which will be stored in a dummy TableView.

Once this dummy table is set with all the data I would call the Platform.runLater to proceed with the UI update of the data in the FXML TableView. Something similar to:

@FXML
private TableView tblTask;

private TableView tblDummy;

.......

try {
     //load all data from database in dummy
     tblDummy = taskDAO.tableTask(loggedUser, tblDummy);

    //Once the data is read copy all data in FXML TableView
    Platform.runLater(new Runnable() {
                    public void run() {     
                        //¿?¿?¿?¿?¿?¿?¿?¿?
                    }

    });

 ....

Is there a straight way to copy the data from the dummy TableView to the FXML TableView?

LazyTurtle
  • 131
  • 1
  • 3
  • 16
  • 2
    Why do you need a "dummy table"? Your DAO should just return the data (as a collection of whatever type of things the table displays). Then do `Platform.runLater(tblTask.getItems().setAll(dataFromDAO));` – James_D Jan 23 '18 at 13:41
  • I have created a method in the DAO where it returns a TableView but as you say I might change it to return only the data from the table. The thing is I want this method for dynamically create TableViews with different column numbers... – LazyTurtle Jan 23 '18 at 13:44
  • Your DAO should know nothing at all about the presentation of the data. It should provide data only. There's nothing to stop you being able to provide different data from the DAO: you don't need to return a `TableView`, just return the data. – James_D Jan 23 '18 at 13:48
  • Ok, thank you for that tip. I will change the DAO, this indeed will make it easier to handle. And it will be done as it is suppose to. – LazyTurtle Jan 23 '18 at 13:51
  • Ok, so I have used the code from [this question](https://stackoverflow.com/questions/42970625/javafx-create-a-dynamic-tableview-with-generic-types) , made it fit my code and it works. – LazyTurtle Jan 23 '18 at 15:11
  • @James_D you can set your comment as answer. I will check it as right. Thank you. – LazyTurtle Jan 29 '18 at 13:55

0 Answers0