//
@SuppressWarnings("unchecked")
@Override
public void decode(FacesContext context, UIComponent component)
{
UIXCollection table = (UIXCollection) component;
Object oldKey = table.getRowKey();
try
{
// Set the row key to null to force the clientId to be correct
table.setRowKey(null);
String selectionParam = __getSelectionParameterName(context, table);
Map<String, String> parameters =
context.getExternalContext().getRequestParameterMap();
_LOG.finest("Params:{0}", parameters);
String selection = parameters.get(selectionParam);
if (selection != null)
{
final RowKeySet state;
if (table instanceof UIXTable)
state = ((UIXTable) table).getSelectedRowKeys();
else
state = ((UIXTree) table).getSelectedRowKeys();
table.setClientRowKey(selection);
if (!state.isContained())
{
RowKeySet unselected = state.clone();
// TODO : do not mutate the selectedRowKeys here.
// instead, mutate when event is broadcast:
state.clear();
state.add();
// clone, so that subsequent mutations of "state" will
// not affect the parameters of this event: bug 4733858:
RowKeySet selected = state.clone();
FacesEvent event = new SelectionEvent(table, unselected, selected);
event.queue();
}
}
}
finally
{
table.setRowKey(oldKey);
}
}