【发布时间】:2012-08-18 19:36:18
【问题描述】:
我有这个对话框:
<p:dialog header="Commande editée le #{acceuilUserController.selectedMajCommande.dateMaj} par l'#{acceuilUserController.selectedMajCommande.utilisateur.type} #{acceuilUserController.selectedMajCommande.utilisateur.nom} #{acceuilUserController.selectedMajCommande.utilisateur.prenom}" widgetVar="carDialog" resizable="false" id="carDlg"
update="cars" showEffect="fade" hideEffect="explode" modal="true">
当用户点击数据表下方的按钮时显示:
<p:column style="width:40px">
<p:commandButton id="selectButton" action="#{acceuilUserController.refresh()}" update=":form:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="plus de détails">
<f:setPropertyActionListener value="#{car}" target="#{acceuilUserController.selectedMajCommande}" />
</p:commandButton>
</p:column>
我希望当用户关闭 tis 对话框时,会执行下面的方法:
public String refresh(){
this.selectedMajCommande.setLu(true);
System.out.println("je suis la alors : "+this.selectedMajCommande.isLu());
hch.updateCommandeMaj(selectedMajCommande);
return "acceuil";
}
它允许将数据刷新到数据表中,我成功地使用对话框中的一个按钮来实现这一点:
<p:commandButton id="confirm" value="fermer" update="cars" oncomplete="carDialog.hide()"
action="#{acceuilUserController.refresh()}" />
但我只想在关闭对话框时执行此操作,不需要框中的此按钮
这是我要刷新的数据表:
<p:dataTable id="cars" var="car" value="#{acceuilUserController.lc_maj}" tableStyle="width:auto" rowStyleClass="#{(car.lu == false) ? 'red' : null}" >
<p:column headerText="Commande N° : " style="width:100px">
<h:outputText value="#{car.commande.id}" />
</p:column>
<p:column headerText="Date de mise à jour : " style="width:100px">
<h:outputText value="#{car.dateMaj}" />
</p:column>
<p:column headerText="Decision : " style="width:100px">
<h:outputText value="#{car.decison}" />
</p:column>
<p:column headerText="Etat : " style="width:100px">
<h:outputText value="#{car.etat}" />
</p:column>
<p:column style="width:40px">
<p:commandButton id="selectButton" action="#{acceuilUserController.refresh()}" update=":form:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="plus de détails">
<f:setPropertyActionListener value="#{car}" target="#{acceuilUserController.selectedMajCommande}" />
</p:commandButton>
</p:column>
</p:dataTable>
如何实现,提前谢谢
【问题讨论】:
-
p:dialog没有update属性。除此之外,PrimeFaces 更新组件的方法是在表单中使用p:ajax来触发服务器端数据的更改。请向我们展示该组件。 -
现在您添加了一些与问题无关的列。我们需要了解是什么事件触发了数据的变化。不然刷新的原因是什么?
-
不是一个完整的解决方案,但您可以将 af:ajax 单击事件添加到对话框中的关闭命令按钮:
并更改 acceuilUserController.refresh(ActionEvent event)。 -
我按照你说的添加这一行:
(因为不支持 event='click')进入我的 ' -
抱歉,它可以工作,问题是我在 RequestScope 中有 managedBean,但现在我使用 ViewScoped 制作它,谢谢
标签: javascript dialog datatable primefaces refresh