Best way to add checkBox into a table ti select the rows

Hi,

I need to add a checkbox into a table by a generated cell, what i need is to use the checkbox to select the rows.
My selection, can also store record that are not into the table.

Just an example.
I show some data into the table, i select some of them
Than i load some other data and select some other.
At the end i need to know wich rows are selected in all the table.

Some ideas

At the moment i use the code attached, but i dont like too mutch.

Thanks for help.

public void select(Object itemId) {
        
        if (!isMultiSelect()) {
            setValue(itemId);

        } else if (!isSelected(itemId) && itemId != null && items.containsId(itemId)) {
            final Set<Object> s = new HashSet<Object>((Set<?>) getValue());
            s.add(itemId);
            setValue(s);
        }

        refreshRowCache();
    }

The only feasible way (without doing big modifications to the table itself) would be to have a valuechangelistener on each checkbox that you create with a GeneratedColumn. have the listener call a util method like the one you have, that adds or removes that row from the actual values of the table (and calling setValue()). Additionally I would probably theme the table so that selected rows look like normal rows; otherwise it might look a little wierd with both the checkbox and the coloring.

Thanks for the answer,

I will give it a try.