@Override
public void populateItem(final Item<ICellPopulator<ObjectAdapter>> cellItem, final String componentId, final IModel<ObjectAdapter> rowModel) {
final MarkupContainer row = cellItem.getParent().getParent();
row.setOutputMarkupId(true);
final EntityModel entityModel = (EntityModel) rowModel;
String concurrencyExceptionIfAny = entityModel.getAndClearConcurrencyExceptionIfAny();
if(concurrencyExceptionIfAny != null) {
row.add(new CssClassAppender("reloaded-after-concurrency-exception"));
}
final ContainedToggleboxPanel toggle = new ContainedToggleboxPanel(componentId) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
final EntityModel entityModel = (EntityModel) rowModel;
ObjectAdapter selectedAdapter = null;
try {
selectedAdapter = entityModel.load(ConcurrencyChecking.CHECK);
handler.onSelected(this, selectedAdapter, target);
} catch(ConcurrencyException ex) {
// should work second time, because the previous attempt will have updated the OAM's OIDs version.
selectedAdapter = entityModel.load(ConcurrencyChecking.CHECK);
handler.onConcurrencyException(this, selectedAdapter, ex, target);
entityModel.setException(ex);
}
}
};
rowToggles.add(toggle);
toggle.setOutputMarkupId(true);