I am adding a checkbox to a table using Table.addGeneratedColumn(), like this:
specimenTable.addGeneratedColumn("selected", new Table.ColumnGenerator() {
@Override
public Component generateCell(Table source, Object itemId, Object columnId) {
CheckBox c = new CheckBox();
selectedCheckBoxes.put(c,itemId);
return c;
}
});
specimenTable.setVisibleColumns(new Object[] {"selected", "specno", "lname", "fname", "MR", "site", "surgdate", "signdate", "att", "diagnosis"});
This appears to work; that is, the checkbox shows up in the UI of the table where it should. However, the HashMap selectedCheckBoxes contains multiple checkboxes for the same table row (itemId), even though only one checkbox is visible, and on investigation generateCell() is called more than once (typically 4) for the same table row (itemID).
I have another table where I’ve used the same construct, and it works; that is, generateCell() is called only once for each row. One difference between the two is that in the one that works the table is created in the constructor for a CustomComponent, whereas in the one that doesn’t work the table is constructed in a Property.ValueChangeListener for another table (when a row in the patients table is selected, the specimen table is created). However, I’ve verified that the specimen table creation code itself runs only once; its only generateCell() that is called repeatedly, apparently by some sort of interrnal UI creation routine (Table.refreshRenderedCells()).
Any enlightenment in this area would be greatly appreciated.
Matthew Fleming, MD
Fleming Dermatopathology