groovygriffonglazedlists

How to observe changes in glazedlists in griffon?


I have a griffon 1.5 application with a glazedlist from which i'm trying to observe changes and bind its size() to a field in the view ..

in my model I have

@Bindable timeslotPicks = 0

@Bindable
@PropertyListener (tableChanged) EventList<ProductionLineEntry> table =
        new BasicEventList<ProductionLineEntry>()  ....

.. and

def tableChanged = {evt->
    println "table Changed ... "
    setTimeslotPicks(table.size())
}

Alas my tableChanged event isn't firing .. How can I bind a view field to the current size of my glazedlist ? Thanks in advance ..


Solution

  • I rejigged my model ..

    EventList<ProductionLineEntry> table =
            new BasicEventList<ProductionLineEntry>()
    ...
    

    and removed my tablechanged check ..

    In my mvcInit controller method I added ..

     // Add a listener to my list ..
        model.table.addListEventListener(
           {e-> model.timeslotPicks = model.table.size()} as ListEventListener
        )
    

    It now works beautifully ..

    Thanks