I'm writing a JavaFX application. I have a TableView
with all entries from a database, populated as follows:
public class AdvertisementListController {
@FXML public TableView<Advertisement> advertisementTable;
@FXML public TableColumn<Advertisement, String> dateColumn;
@FXML public TableColumn<Advertisement, String> productColumn;
@FXML public TableColumn<Advertisement, String> vendorColumn;
@FXML public TableColumn<Advertisement, Integer> priceColumn;
@FXML public TableColumn<Advertisement, Integer> quantityColumn;
// ...
public void initialize() {
dateColumn.setCellValueFactory(new PropertyValueFactory<>("stringDate"));
productColumn.setCellValueFactory(new PropertyValueFactory<>("productName"));
vendorColumn.setCellValueFactory(new PropertyValueFactory<>("vendorId"));
priceColumn.setCellValueFactory(new PropertyValueFactory<>("price"));
quantityColumn.setCellValueFactory(new PropertyValueFactory<>("quantity"));
// ...
AdvertisementDAO advertisementDAO = new AdvertisementDAO();
annunciTable.setItems(advertisementDAO.getAdvertisementObservableList());
}
From another window of my application I can insert new entries in the table of the database. I'm new to GoF patterns, and I'm trying to implement here an Observer pattern in order to keep the table updated, but I don't really know where to start. What's the subject here? What's the Observer class?