Menu

something happens with notifyObservers()

Help
2007-08-14
2013-04-08
  • Nacho Espinosa

    Nacho Espinosa - 2007-08-14

    Hi tomi:

    I'm using a YTable. When I have in the table values and I select the first value in the table, I get an object. In this object I get a property and I set in the bean (model), but when I put the method notifyObservers(), the value in not showed in the view, and the method SelectionChanged(Object object) is recalled again in the controller.

    This is a bug? or what happen with this case?

     
    • Tomi Tuomainen

      Tomi Tuomainen - 2007-08-15

      When you call notifyObservers() the whole table will be updated (Collection will be copied from YModel to your table). When a table model is recreated, you lose the selection. Therefore, selectionChanged is called again with null.

      But I'm not sure why your change is not updated to the table. YTable actually holds same objects as YModel, so if you update an object property, the change should be reflected to table without calling notifyObservers at all. Check what is actually in your YModel Collection after you have changed the row object. And add "if (object != null)" to your selectionChanged method. 

      Tomi

       

Log in to post a comment.