سؤال

My problem is that I want to use a collection type with new PropertyValueFactory<,>()

TableColumn columnname = new TableColumn("Nom");
columnname.setCellValueFactory(new PropertyValueFactory<NoteBean, List>("name"));

because my NoteBean contains a field of type collection (List).

Thank you ;).

هل كانت مفيدة؟

المحلول

the solution for my problems is to parse the collection with for or while using this code :

    TableColumn<Person,String> firstNameCol = new TableColumn<Person,String>("First Name");
 firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
     public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
         return p.getValue().firstNameProperty();
     }
  });
 }

for exemple :

TableColumn columnmod = new TableColumn<ModuleNoteBean, Double>(
                moBean.getModuleBean());
        for (int i = 0; i < moBean.getListmat().size(); i++) {
            TableColumn columnNote = new TableColumn(moBean.getList_mat()
                    .get(i));
            final int index = i;
            columnNote
                    .setCellValueFactory(new Callback<CellDataFeatures<ModuleNoteBean, String>, ObservableValue<String>>() {

                        public ObservableValue<String> call(
                                CellDataFeatures<ModuleNoteBean, String> p) {

                            SimpleStringProperty b = new SimpleStringProperty(p
                                    .getValue().getModuleNList().get(0)
                                    .getNoteList().get(index)
                                    + "");

                            return b;
                        }
                    });

PropertyValueFactory

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top