1 Reply Latest reply: Nov 4, 2012 9:58 PM by 972422 RSS

    JavaFX and databases

    968989
      Hi,
      I'm wondering about using ObservableLists / Maps for tracking changes and updating the database.

      I'd be pleased if anyone can provide directions for this.
        • 1. Re: JavaFX and databases
          972422
          Your question is a bit confused. I'm new to javaFX so as far as I know the ObservableList/Map are use to store data in TableView. You can use the Java class that map the table in database for ObservaleList. Here is the tutorial that create a TableView that have cell that can be editable(Example 13-10) :
          http://docs.oracle.com/javafx/2/ui_controls/table-view.htm
          The edit data will also be updated to the ObservableList in this code
          emailCol.setOnEditCommit(
          new EventHandler<CellEditEvent<Person, String>>() {
          @Override
          public void handle(CellEditEvent<Person, String> t) {
          ((Person) t.getTableView().getItems().get(
          t.getTablePosition().getRow())
          ).setEmail(t.getNewValue());
          }
          }
          );

          You can get the editted items out and update to the the database in the handle. Something like this :
          //get the updated item from the ObservableList;
          Person updatedPerson = (Person) t.getTableView().getItems().get(t.getTablePosition().getRow());
          //update the changed item to database
          update(updatedPerson);


          Hope this will help you