문제

I have TableView with number of columns, I have set onEditCommit method on the first column to get the value inserted and then retrieve data from database based on that value and set the retrieved data in other columns. the table couldn't update it's content.

accountNoCol.setOnEditCommit(new EventHandler<CellEditEvent<Bond, String>>() {
        @Override
        public void handle(CellEditEvent<Bond, String> event) {
            String newValue = event.getNewValue();
            Bond bond = event.getRowValue();
            int selectedRow = event.getTablePosition().getRow();
            if (isInteger(newValue)) {
                ((Bond) event.getTableView().getItems().get(
                        event.getTablePosition().getRow())).setAccountNo(newValue);

                if (isDebtAccount(newValue)) {
                    String accountName = getDebtAccountName(newValue);
                    String coinName = getCoinName(newValue);
                    float coinExchange = getCoinExchange(newValue);

                    bond.setAccountName(accountName);
                    bond.setCoinName(coinName);
                    bond.setCoinExchange(coinExchange);



                    bondTable.getSelectionModel().select(selectedRow, statementCol);

                } else if (isNonDebtAccount(newValue)) {
                    String accountName = getNonDebtAccountName(newValue);
                    bond.setAccountName(accountName);
                    bond.setCoinName(getDefaultCoinName());
                    bond.setCoinExchange(1);



                    bondTable.getSelectionModel().select(selectedRow, statementCol);
                } 
                else {
                    System.out.println("wrong acount name");
                    // show accounts table - i guess
                }
            } else {
                if (newValue.length() == 0) {
                    System.out.println("length : " + newValue.length());
                    ((Bond) event.getTableView().getItems().get(
                            event.getTablePosition().getRow())).setAccountNo(newValue);
                }
            }
        }
    });

I tried to use this next line but the table get crashed after adding new rows

bondData.set(selectedRow,Bond);
도움이 되었습니까?

해결책

Solved. The problem was the table get crashed when am trying to open new stage from a listener on a tablecolumn. so on listener and before fire my action which is opening new stage i set the tablecolumn uneditable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top