我有两个映射和链接的表(PositionResource和PositionCurrency),我想将它们绑定在一个表中,这样两个列来自一个表,一个列来自另一个表。我完成了这项工作:
@FXML
private TableView<PositionResource> tv_loro_nostro_accounts;
@FXML
private TableColumn<PositionResource, String> tc_account;
@FXML
private TableColumn<PositionResource, String> tc_acc_name;
@FXML
private TableColumn<PositionCurrency, String> tc_currency;
和绑定如下。关系是一对多(一个PositionCurrency可以有许多PositionResource)
tc_account.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getBrief()));
tc_acc_name.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getName()));
tc_currency.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getBrief()));
例外是:
线程中的异常&#34; JavaFX应用程序线程&#34; java.lang.ClassCastException:ru.com.isbank.adc.adc_common.model.position.PositionResource无法强制转换为ru.com.isbank.adc.adc_common.model.position.PositionCurrency