jsf - PrimeFaces DataTable CellEdit get entity/object -
i have datatable displays various entities based on list<>. when select cell editing want able entity somehow in order update it. of course there event.getrowindex, can use list<>, not convenient. there perhaps way entity celleditevent?
one way programmatically el-evaluate current <p:datatable var>.
given a
<p:datatable value="#{bean.entities}" var="entity"> you 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 celleditevent argument, override celleditevent argument altogether passing iterated entity argument instead:
<p:ajax event="celledit" listener="#{bean.oncelledit(entity)}" /> with
public void oncelledit(entity entity) { // ... } please note cannot keep celleditevent , pass additional arguments. answer otherwise have been given.
Comments
Post a Comment