Reputation: 257
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 ..
Upvotes: 1
Views: 98
Reputation: 257
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
Upvotes: 0
Reputation: 3281
The problem is that you're observing changes made to the table
field, and not the contents of the table
field as you expect. In other words, the code you've written (the tableChanged
closure) reacts when bean.table
is updated, for example, when a new EventList
is assigned to that field.
You must write a ListChangeListener
in order to adapt list changes to list size.
Upvotes: 0