Thanks, makes sense, but does lead me to another issue, if I have a
different mouseListener instance created for each model Object then
how do I detach them i.e remember them all to detach correct one ?.
for example in onAttach I create the specific listener
public void onAttach(final Object modelObject, final
TableBodyGroup rowGroup) {
rowGroup.addMouseListener(rowGroupMouseListener);
final Iterator iter = rowGroup.getRows().iterator();
while (iter.hasNext()) {
final TableRow tr = (TableRow)iter.next();
tr.addMouseListener(new
RowMouseListener(modelObject));
}
}
but then in detach.. I don't know which instance to detach, unless I
maintain some kind of Map maybe of modelObject key to value
mouseListener.
public void onDetach(final Object obj, final TableBodyGroup
rowGroup) {
rowGroup.removeMouseListener(rowGroupMouseListener);
final Iterator iter = rowGroup.getRows().iterator();
while (iter.hasNext()) {
final TableRow tr = (TableRow)iter.next();
tr.removeMouseListener(?????);
}
}
Any thoughts?
I must admit I don't fully understand all the attach/detach stuff but
appreicate I need it to allow references to be released.
Doing it the other way, with a single mouseListener for all rows
works, but as mentioned before I had to add a hidden cell with an Id
in it, and then I work from the clicked row, which cells represents a
hidden Id field, then iterate through the
ObjectListTables.getObjects() to find the matching modelObject. This
does work but seems a little clunky.