Sorting 排序后,它将删除primefaces数据表的错误行
我有一个primefaces数据表,其中有一列包含删除关联行的commandButton。当我对datatable排序并删除一行时,它会删除排序之前位于该位置的行 例如,假设datatable中有5行:Sorting 排序后,它将删除primefaces数据表的错误行,sorting,jsf,primefaces,datatable,Sorting,Jsf,Primefaces,Datatable,我有一个primefaces数据表,其中有一列包含删除关联行的commandButton。当我对datatable排序并删除一行时,它会删除排序之前位于该位置的行 例如,假设datatable中有5行: line 1 with id=12 line 2 with id=10 line 3 with id=25 line 4 with id=36 line 5 with id=1 现在假设我按id对行进行排序。我获得行: line 1 with id=1 (previously line 5)
line 1 with id=12
line 2 with id=10
line 3 with id=25
line 4 with id=36
line 5 with id=1
现在假设我按id对行进行排序。我获得行:
line 1 with id=1 (previously line 5)
line 2 with id=10 (previously line 2)
line 3 with id=12 (previously line 1) <---------------
line 4 with id=25 (previously line 3)
line 5 with id=36 (previously line 4)
以及按钮的代码:
<p:commandButton actionListener="#{notifController.delete(notif)}"
update=":formNotifs :formNotif"/>
您是否有按钮+操作(侦听器)的代码?是的,我已编辑我的问题是的,它们已被覆盖。。但它并不总是删除第一行,而是删除排序之前位于该位置的行
public void delete(Notif notif) {
try {
notifService.deleteNotif(notif);
listNotifs.remove(notif);
} catch (Exception e) {
if (e instanceof DataIntegrityViolationException) {
LOGGER.error(e.getStackTrace());
}
}
}
<p:commandButton actionListener="#{notifController.delete(notif)}"
update=":formNotifs :formNotif"/>