//
@SuppressWarnings("unchecked")
@Override
public void decode(FacesContext context, UIComponent component)
{
UIXCollection table = (UIXCollection) component;
Object oldKey = table.getRowKey();
table.setRowIndex(-1);
String tableId = table.getClientId(context);
Map<String, String[]> parameters =
context.getExternalContext().getRequestParameterValuesMap();
String[] unselectedBoxes =
parameters.get(tableId+NamingContainer.SEPARATOR_CHAR+UNSELECTED_KEY);
// check to see if there were any selection boxes in the request.
// if there were no unselected boxes, then there can't be any selected
// ones either:
if ((unselectedBoxes == null) || (unselectedBoxes.length == 0))
return;
String[] selectedBoxes =
parameters.get(tableId+NamingContainer.SEPARATOR_CHAR+SELECTED_KEY);
// must work with both table and hgrid:
final RowKeySet selectionModel;
if (table instanceof UIXTable)
selectionModel = ((UIXTable) table).getSelectedRowKeys();
else
selectionModel = ((UIXTree) table).getSelectedRowKeys();
// Object selectMode = tableMap.get(UIConstants.SELECT_MODE_KEY);
// // select-all/none across all ranges (both visible and invisible)
// // is disabled for EA6. This is because it is pretty bad if in the email
// // demo the user does a select-all followed by delete and all of his/her
// // messages (including the ones that are currently not visible) are deleted.
// if (false && (selectMode != null))
// {
// if ("all".equals(selectMode))
// selectionModel.addAll();
// else if ("none".equals(selectMode))
// selectionModel.clear();
//
// // even if we do a select all/none we still need to run through the
// // regular per row selection code below. this is because the user might
// // have clicked select-all and then deselected some rows before submitting:
// }
RowKeySet selectedDelta = selectionModel.clone();
selectedDelta.clear();
RowKeySet unselectedDelta = selectedDelta.clone();
_setDeltas(table, selectedBoxes, unselectedBoxes,
selectionModel, selectedDelta, unselectedDelta);
if ((selectedDelta.getSize() != 0) || (unselectedDelta.getSize() != 0))
{
FacesEvent event =
new SelectionEvent(table, unselectedDelta, selectedDelta);
event.queue();
}
table.setRowKey(oldKey);
}