关闭 p:dialog 后如何刷新页面 [英] How to refresh the page after closing p:dialog

查看:38
本文介绍了关闭 p: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>

关闭对话框后如何刷新 JSF 页面?

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

推荐答案

<p:dialog> 支持 ajax close 事件.这只需要将它放在 <h:form> 内(与 一般建议相反),因此您需要确保它已经手动定位到 <h:body> 的最后,并且您没有使用 appendToBody.

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>

如果您打算更新整个页面,请在必要时使用update="@all".但更好的是只更新真正需要更新的部分.

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.

这篇关于关闭 p:dialog 后如何刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆