// final ScrollableDataTableRendererState state =
// ScrollableDataTableRendererState.createState(context, grid);
// state.setRowIndex(ScrollableDataTableUtils.getClientRowIndex(grid));
Object savedKey = table.getRowKey();
final TableHolder holder = new TableHolder(table);
final SimpleSelection simpleSelection = table.getSelection() == null ? new SimpleSelection()
: (SimpleSelection) table.getSelection();
if (clientSelection.isReset() || clientSelection.isSelectAll()) {
simpleSelection.clear();
}
try {
table.walk(context, new DataVisitor() {
public void process(FacesContext context, Object rowKey,
Object argument) throws IOException {
// TableHolder holder = (TableHolder) argument;
// int i = state.getRowIndex();
int i = holder.getRowCounter();
if (shouldAddToSelection(i, oldClientSelection,
clientSelection)) {
simpleSelection.addKey(rowKey);
} else if (shouldRemoveFromSelection(i,
oldClientSelection, clientSelection)) {
simpleSelection.removeKey(rowKey);
}
if (i == clientSelection.getActiveRowIndex()) {
table.setActiveRowKey(rowKey);
}
holder.nextRow();
}
}, holder);
} catch (IOException e) {
throw new FacesException(e);