0 Replies Latest reply: Nov 8, 2012 11:42 AM by 973303 RSS

    ListView ChangeListener behaving badly

    973303
      I have a ListView in am FXML project the controller has this method

      public void initialize(URL url, ResourceBundle rb) {

      memebersListView.setItems(FXCollections.observableList(mbq.getAllEnterpriseMembersAlpha()));

      memebersListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<EnterpriseMember>() {

      @Override
      public void changed(ObservableValue<? extends EnterpriseMember> ov, EnterpriseMember t, EnterpriseMember t1) {
      System.out.println(t1.toString());
      }
      });

      The FXML loads correctly and the memebersListView has all the right data in it from the EnterpriseMember. mbq.getAllEnterpriseMembersAlpha() is like this

      private EntityManagerFactory emf = Persistence.createEntityManagerFactory("xxPU");
      private EnterpriseMemberJpaController emjc = new EnterpriseMemberJpaController(emf);

      private EntityManager em = emf.createEntityManager();
      public List<EnterpriseMember> getAllEnterpriseMembersAlpha(){
      List<EnterpriseMember> ems = em.createQuery("SELECT p FROM EnterpriseMember p ORDER BY p.secondName").getResultList();
      return ems;
      }

      When I click for the first time the changeListener is notified correctly and the toString() prints a representation of the object. However if I select another one from the list i get nothing.
      And I really mean nothing the changelistener.change() method is never reached (I have had the debugger on to check this).

      Anyone any idea what is happening here. (I have used listview in this way before and just can't spot a difference)