ped*_*dro 4 updates primefaces
每次弹出时,我都试图更新一个primefaces对话框。该对话框由更改日历字段触发,实际调用是从 bean 进行的。当我第一次调用它时,数据很好,但是,如果我关闭它并再次打开它,它仍然会显示旧数据。这有点道理:它只渲染一次,然后显示和隐藏,从未真正更新。
我正在考虑在 bean 中的 dialog.show() 之前更新它,但我不知道该怎么做。任何的想法?
<p:dialog
site ="sectionDlg"
widgetVar ="Dlg"
minWidth ="430"
modal ="true"
closable ="true"
resizable ="false"
dynamic ="true"
width="450" height="300"
>
<h:form id="Form">
<br/>
<p:panelGrid id ="dates" styleClass="cmt-no-grid-100perc" columns="4">
<calendar attribName ="offerStartDateDlg"
value ="#{bean.startDate}"
writable ="#{false}"/>
<calendar attribName="offerEndDateDlg"
value="#{bean.endDate}"
writable="#{false}"/>
</p:panelGrid>
<div align="center">
<p:commandButton
onclick ="PF('whichSectionDlg').hide()"
>
</p:commandButton>
<p:commandButton
onclick ="PF('whichSectionDlg').hide()">
</p:commandButton>
</div>
</h:form>
Run Code Online (Sandbox Code Playgroud)
这可以让事情变得更容易
好的,我设法弄清楚了。
我通过在调用之前从 bean 更新它来解决它
public void show_dlg_method(){
RequestContext.getCurrentInstance().update("Dlg");
RequestContext.getCurrentInstance().execute("PF('Dlg').show()");
}
Run Code Online (Sandbox Code Playgroud)
“Dlg”是 widgetVar 属性值。
您已有的一些代码总是有帮助的。但是,根据触发对话框显示的原因,您可以:
update到触发链接/按钮/任何或<h:form>
<p:remoteCommand name="updateDialog" update="dialogpanelid" />
</h:form>
<dialog onShow="updateDialog">
<p:outputPanel id="dialogpanelid"> your content here </p:outputPanel>
</dialog>
Run Code Online (Sandbox Code Playgroud)
注意:
remoteCommand住在里面h:form