Presentation of object in tableview



  • There's a salary {id, year, month, empl{id, name, adress}

    So we're looking at it and it's working, but how do we do it with the empl?

    salaryYear.setCellValueFactory(new PropertyValueFactory<Salary, String>("years"));
    

    I'll miss it.

    salaryFirstName.setCellValueFactory(cellData  -> cellData.getValue().getEmployeesByEmpl().getFirstName());
    

    But he does.

    "bad return type in lambda expression
    java.lang.String cannot be converted to javafx.beans.value.ObservableValue<java.lang.String>"
    

    That's how it goes. There's a table, there's a data sheet.

    (1) These fields are displayed

    salaryYear.setCellValueFactory(new PropertyValueFactory<Salary, String>("years"));
     salaryMonth.setCellValueFactory(new PropertyValueFactory<Salary, String>("month"));
    

    And that's not,

    salaryFirstName.setCellValueFactory(cellData  -> cellData.getValue().getEmployeesByEmpl().getFirstName());
    

    (2) I'm trying to figure this out:

    employees.setAll(Factory.getEmplDAO().getAllEmpl());
    tableEmpl.setItems(employees);
    

    It would be good if you didn't have to change the entity. How can you fix that?



  • You have a method. getFirstName() I've got to go back to the line. https://docs.oracle.com/javase/8/javafx/api/javafx/beans/property/StringProperty.html ♪




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2