I have used onEditCommit event in Fxml to retrive data after user edit it.
FXML Code -:
I made these changes. in EditingCell.java
public class EditingCell extends TableCell<Record, String> {
in EditController.jva added just TableColumn
public void columnEdit(TableColumn.CellEditEvent<Record,String> event)
Your event handler type looks fine to me. My guess is the type mismatch is occurring elsewhere.
Sample
Here is a sample which demonstrates setting a commit event handler when using FXML. Apologies for the verbosity, that's just how FXML is.
The edit commit handler in the sample is:
@FXML
void commitValue(TableColumn.CellEditEvent<Singular, String> event) {
System.out.println("Commit: " + event.getNewValue());
}
where Singluar is just the name of the record class used in the TableView for the sample.
commit/CommitController.java
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
public class CommitController {
@FXML
private TableView<Singular> table;
@FXML
private TableColumn<Singular, String> value;
@FXML
void commitValue(TableColumn.CellEditEvent<Singular, String> event) {
System.out.println("Commit: " + event.getNewValue());
}
public void initialize() {
value.setCellFactory(TextFieldTableCell.forTableColumn());
value.setCellValueFactory(new PropertyValueFactory<>("value"));
value.setEditable(true);
table.getItems().setAll(
new Singular("enie"),
new Singular("meenie"),
new Singular("minie"),
new Singular("moe"),
new Singular("just commit!")
);
table.setEditable(true);
}
public static class Singular {
private StringProperty value = new SimpleStringProperty();
public Singular(String value) {
this.value.setValue(value);
}
public StringProperty valueProperty() {
return value;
}
}
}
commit/CommitmentApp.java
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class CommitmentApp extends Application {
@Override
public void start(Stage stage) throws IOException {
stage.setScene(new Scene(createContent()));
stage.show();
}
private Parent createContent() throws IOException {
FXMLLoader loader = new FXMLLoader();
return loader.load(
getClass().getResourceAsStream("commit.fxml")
);
}
public static void main(String[] args) {
launch(args);
}
}
commit.fxml
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<TableView fx:id="table" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="130.0" prefWidth="113.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="commit.CommitController">
<columns>
<TableColumn fx:id="value" onEditCommit="#commitValue" prefWidth="85.0" text="C1" />
</columns>
</TableView>