【发布时间】:2016-04-24 22:29:05
【问题描述】:
我正在使用 JSF2.2 Majorra 和 Primefaces 5.1 构建一个 Web 应用程序。
我有一个对话框,我需要验证,当有效时,执行操作。
在我调用的那个动作方法中,我可能会也可能不会发送一些 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.");
}
}
但是,在提交按钮的 oncomplete 中,我告诉对话框在验证没有失败时消失,如下所示:
<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 从操作方法中关闭对话框,但由于 close-POST 似乎总是最后一个,所以这没有奏效。
我使用的模板涉及到一个 navigation.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>
我摆弄了按钮和咆哮的属性,但是当我关闭对话框时,消息不断消失。 这个我好像搞不清楚。
有什么想法吗?
【问题讨论】:
-
我在你的代码中看不到任何咆哮......请创建一个minimal reproducible example。您很可能在咆哮中有“自动更新”之类的东西?
-
试过删除 autoUpdate="true" 吗?
-
它不是唯一一个使用咆哮容器的页面,所以我很遗憾地将 autoUpdate 设置为 true
-
T R Y 。 . .请。如果它发挥作用,你有更多的信息......
标签: ajax jsf-2 primefaces