How to refresh the page after closing p:dialog

可紊 提交于 2019-12-19 03:31:52

问题


I've the below dialog:

<h:form id="r1">
  <p:commandButton value="Basic" type="button" onclick="PF('dlg1').show();" />
  <p:dialog header="Basic Dialog" widgetVar="dlg1">
    <h:outputText id="test" value="Welcome to PrimeFaces" />
  </p:dialog>
</h:form>

How can I refresh the JSF page after closing the dialog?


回答1:


The <p:dialog> supports the ajax close event. This only requires it being placed inside a <h:form> (on contrary to the general recommendation), so you need to make sure that it's already manually poisitioned to the very end of the <h:body> and that you don't make use of appendToBody.

<h:body>
    <h:panelGroup id="content" layout="block">
        ...
    </h:panelGroup>

    ...

    <h:form>
        <p:dialog>
            <p:ajax event="close" update=":content" />
            ...
        </p:dialog>
    </h:form>
</h:body>

Use if necessary update="@all" if you intend to update the entire page. But better is to update only the parts which really need to be updated.



来源:https://stackoverflow.com/questions/30107167/how-to-refresh-the-page-after-closing-pdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!