PrimeFaces DataTable CellEdit get entity/object

前端 未结 3 2124
栀梦
栀梦 2021-02-14 04:40

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.

3条回答
  •  孤独总比滥情好
    2021-02-14 04:43

    I have been struggling with this problem two and I didn't like depending the var name so I found this solution:

    public void onCellEdit(CellEditEvent event) {  
        Entity entity =(Entity)((DataTable)event.getComponent()).getRowData();
    }
    

    note that the entity is updated can be merged directly into the DB, also you can still get the old value. PS: thank you @BalusC for everything :)

提交回复
热议问题