Primefaces:关闭对话框时,咆哮消息立即消失



我正在使用JSF2.2 Majorra&Primefaces 5.1构建一个Webapp。

我有一个对话框,我需要验证,当有效时,执行操作。

在我调用的那个操作方法中,我可能会也可能不会发送一些 p:growl 消息。他们出现了,我看到了他们:

if (conflict >= 1) {
    try {
        if (!user.getId().equals(projektLeiter.getId())) {
            logger.info("CONFLICT.........................sending notification email to "
                    + projektLeiter.getFullName() + " with email " + projektLeiter.getEmail());
            EMailUtil.sendMailForOverlap(projektLeiter, currentProject, absence);
            MessageUtil.showGrowlWarn("Eventkonflikt festgestellt!<br/><br/>Leiter des Projekts '"
                    + currentProject.getNameShort() + "' wurde informiert.");
            RequestContext.getCurrentInstance().update("btnForm:growl");
        } else {
            MessageUtil.showGrowlWarn(
                    "Eventkonflikt mit Projekt '" + currentProject.getNameShort() + "' festgestellt!");
        }
    } catch (MessagingException e) {
        logger.catching(e);
        MessageUtil.showGrowlError(
                "Fehler: Kann keine Emails verschicken! Bitte informieren Sie den Administrator.");
    }
}
但是,在

提交按钮的完成中,我告诉对话框在验证未失败时消失,如下所示:

<p:commandButton value="Speichern" process="detailsBookingDlg"
    update=":dialogForm:detailsBookingInner :dataTableForm:absenceTable"
    action="#{absenceController.onSaveButtonClick}"
    oncomplete="if (!args.validationFailed) {PF('detailsBookingWdgt').hide()}" />

我使用网络包资源管理器来查找问题。有一个额外的 POST 用于关闭对话框:

http://s21.postimg.org/6f0nylbs7/close.png

这个帖子让我的消息消失了。所以问题就来了。当我拿出 oncomplete 时,它们会留下来。

在显示消息之前,我尝试使用 RequestContext 从操作方法关闭对话框,但这不起作用,因为关闭 POST 似乎总是最后一个。

我使用一个涉及导航.xhtml的模板,其中包括 p:growl:

<h:form id="btnForm">
    <div id="welcomeMessage">
        <h:outputText value="#{sessionBean.welcome}" escape="false" />
    </div>
    <p:growl id="growl" showDetail="false" life="10000" autoUpdate="true" redisplay="true" globalOnly="true"
        escape="false" />
</h:form>

我摆弄了按钮和咆哮的属性,但是当我关闭对话框时,消息不断消失。我似乎无法弄清楚这一点。

有什么想法吗?

我的一位同事找到了答案:

在有问题的对话框中,我有一个 p:ajax 事件:

 <p:ajax event="close" immediate="true" update=":mainForm:timeline"
                listener="#{absenceAdministrationController.onCancelButtonClick}" />

每次我隐藏对话框时都会调用它。此事件仅在单击右上角的小"x"时触发,我完全摆脱了。

我在对话框中添加了一个"取消"按钮,并使其可关闭="false"。

这解决了我隐藏一些消息的问题。

最新更新