I have a datatable which displays various entities based on a List<>. When I select a cell for editing I want to be able to also get the entity somehow in order to update it.
One way would be to programmatically EL-evaluate the current
.
Given a
you could get it as follows
public void onCellEdit(CellEditEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
Entity entity = context.getApplication().evaluateExpressionGet(context, "#{entity}", Entity.class);
// ...
}
Another way, if you're not interested in the CellEditEvent
argument, would be to override the CellEditEvent
argument altogether by passing the currently iterated entity as argument instead:
with
public void onCellEdit(Entity entity) {
// ...
}
Please note that you cannot keep the CellEditEvent
and pass additional arguments. This answer would otherwise obviously have been given.