I am absolutely new to coding and am stuck with some "binding" code. I have a Record class with getters and setters, and a records Observable list which together populate a Tableview in a controller called RecordController. I want to populate another tableview on a separate AdminController file both with different view fxml's.
How can I bind the SimpleStringProperties in my Record.java class in such a manner that when they get updated by by the set method( by any UI user interaction) in RecordContoller ..the (editatble) Tableview in the AdminController gets populated with the new values.
Some bits of the code.....
public class Record {
private final SimpleStringProperty stationName;
private final SimpleStringProperty staffName;
private final SimpleStringProperty staffNumber;
private final SimpleStringProperty agencyName;
private final SimpleStringProperty aircraftType;
private final SimpleStringProperty issueDate;
private final SimpleStringProperty validTill;
public Record(String stationName, String staffName,
String staffNumber, String agencyName, String aircraftType,
String issueDate, String validTill) {
this.stationName = new SimpleStringProperty(stationName);
this.staffName = new SimpleStringProperty(staffName);
this.staffNumber = new SimpleStringProperty(staffNumber);
this.aircraftType = new SimpleStringProperty(aircraftType);
this.agencyName = new SimpleStringProperty(agencyName);
this.issueDate = new SimpleStringProperty(issueDate);
this.validTill = new SimpleStringProperty(validTill);
}
public String getStationName() {
return stationName.getValue();
}
public String getStaffName() {
return staffName.getValue();
}
public String getStaffNumber() {
return staffNumber.getValue();
}
public String getAgencyName() {
return agencyName.getValue();
}
public String getAircraftType() {
return aircraftType.getValue();
}
public String getIssueDate() {
return issueDate.getValue();
}
public String getValidTill() {
return validTill.getValue();
}
}
And the RecordController with the first Tableview.....
columnStation.setCellValueFactory(new PropertyValueFactory<>("stationName"));
columnStaffName.setCellValueFactory(new PropertyValueFactory<>("staffName"));
columnStaffNumber.setCellValueFactory(new PropertyValueFactory<>("staffNumber"));
columnAgency.setCellValueFactory(new PropertyValueFactory<>("agencyName"));
columnAircraftType.setCellValueFactory(new PropertyValueFactory<>("aircraftType"));
columnIssueDate.setCellValueFactory(new PropertyValueFactory<>("issueDate"));
columnValidTill.setCellValueFactory(new PropertyValueFactory<>("validTill"));
recordTableView.setItems(null);
recordTableView.setItems(records);
The records observable list being .....
private ObservableList<Record> records=FXCollections.observableArrayList();
The adminController for the other fxml also has another tableview which I want to populate in some way with the property variables in the Record.java (class / bean ? ).