• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Notify ObservableList Listeners of a Change in One of Its Elements

 
Ranch Hand
Posts: 49
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

I want objects listening to changes in my ObservableList to be notified of changes in one of its elements without needing to remove the element and add a new one in its place. I hope I make myself clear. Right now, to trigger change event, I need to write the code as follows (create a tempItem):

 
Rancher
Posts: 387
30
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use an extractor to register for update notifications on the properties of the item that you want to listen to updates on.

Here is a sample:



Sample Output:



Note that the update notification is received, when the description of the apple changed from Green Skin to Red Skin as the apple ripened. Without an extractor definition, this update notification would not be received.
 
Mike Matthews
Ranch Hand
Posts: 49
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Thank you kindly for your reply. I already solved the problem using exactly this solution (extractor.) It worked perfectly. I added the extractor() method to my Item class so now it looks as follows:


I used ListProperty<Item> to store items. Hopefully it will help someone else in the future.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for reopening this post again. I have this problem, except a have one more layer: I don't have the properties, but instead the class
has objects of other classes. Example:





How do I notify the list (of course wrapped in ObservableList), if setNextLayer is called and the object is changed?
 
    Bookmark Topic Watch Topic
  • New Topic