提问人:Maria 提问时间:12/2/2022 最后编辑:Maria 更新时间:12/2/2022 访问量:67
使用 p:confirmDialog 删除行后更新 p:dataTable
Update p:dataTable after deleting a row with p:confirmDialog
问:
我正在使用 a 来显示玩家列表。我有一列用于从数据库中删除玩家。此列有一个 ,它触发一个 .确认对话框按钮应同时排除播放器并刷新表。
删除工作正常,但我似乎无法以任何方式自动刷新数据表。p:dataTable
p:commandButton
p:confirmDialog
代码是这样的:
这:.xhtml
<h:form id="form" >
<p:growl/>
<div class="bloco">
<h2>PLAYERS</h2>
<p:dataTable value="#{adminPlayersBean.players}" var="p"
paginator="true" paginatorAlwaysVisible="true"
paginatorPosition="bottom" rows="8">
// some columns
<p:column headerText="X">
<p:commandButton action="#{adminPlayersBean.remove(p)}"
update="@form" immediate="true"
styleClass="ui-button-danger" icon="pi pi-times">
<p:confirm header="Delete player" message="Delete #{p.getNickname()}?" />
</p:commandButton>
</p:column>
// ...
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade"
responsive="true" width="430" >
<p:commandButton value="✓ Yes" type="button" styleClass="ui-confirmdialog-yes"/>
<p:commandButton value="X No" type="button" styleClass="ui-confirmdialog-no" />
</p:confirmDialog>
//...
在 bean 中:
@Named
@ViewScoped
public class AdminPlayersBean implements Serializable {
private List<Player> players;
public void remove(Player player) {
playerController.remove(player); //deletes the player from DB
this.players = playersController.findAll(); //updates the List that fills the dataTable
PrimeFaces.current().ajax().update(":form");
}
我已经尝试将更新从 .xhtml 更改为:
update=":form"
update="@form"
- 此外,在 和 尝试
p:dataTable
update=":form:table"
在 Bean 中,我尝试过:
PrimeFaces.current().ajax().update(":form");
PrimeFaces.current().ajax().update("@form");
- 等
我错过了什么?
谢谢!
答: 暂无答案
评论