Jsf 如何使Primefaces咆哮堆栈消息?

Jsf 如何使Primefaces咆哮堆栈消息?,jsf,primefaces,Jsf,Primefaces,命令按钮显示咆哮声。但是之前的咆哮信息丢失了。如何使咆哮显示消息堆栈 例如: <h:form> <p:growl id="growl" showDetail="true" life="6000" /> <p:commandButton value="Show" actionListener="#{growlView.showMessage}" update="growl" /> </h:form> 我每秒钟点击一次按钮。

命令按钮显示咆哮声。但是之前的咆哮信息丢失了。如何使咆哮显示消息堆栈

例如:

<h:form> 
    <p:growl id="growl" showDetail="true" life="6000" />  
    <p:commandButton value="Show" actionListener="#{growlView.showMessage}" update="growl" />  
</h:form>
我每秒钟点击一次按钮。我预计消息将存储并显示6秒钟。 但单击按钮后,上一条消息隐藏,我只看到当前消息

当我调试时,我有:

FacesContext.getCurrentInstance().getMessageList().size() == 0
我试过了

FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);


org.primefaces.messagePersistence
符合事实的
但这是行不通的=(


请帮助

不幸的是,这目前不可能。事实上,这是2011年的默认行为(有大量咆哮消息),但primefaces核心团队决定:

在ajax更新上显示新消息之前隐藏以前的消息

资料来源:


但是,为恢复此功能创建了一个问题(2014年10月),但尚未进行审查。

不幸的是,这目前不可能实现。实际上,这是2011年的默认行为(有大量咆哮消息),但primefaces核心团队已决定:

在ajax更新上显示新消息之前隐藏以前的消息

资料来源:


然而,产生了一个问题(2014年10月)要恢复此功能,但尚未审查。

对于那些希望以相同的方式在堆栈上显示消息而不隐藏以前消息的人,使用primefaces 5.1的一个简单解决方案是覆盖组件的默认行为,将primefacesFixes.js文件添加到类路径并覆盖具有以下注释行的函数:

primefacesFixes.js:

PrimeFaces.widget.Growl.prototype.show = function(b) {
var a = this;
this.jq.css("z-index", ++PrimeFaces.zindex);
//this.removeAll(); //Commenting this line prevents an ajax update tho the <p:growl> from erasing global messages
$.each(b, function(c, d) {
    a.renderMessage(d);
});
PrimeFaces.widget.Growl.prototype.show=函数(b){
var a=此;
css(“z-index”++PrimeFaces.zindex);
//this.removeAll();//注释此行可防止ajax更新删除全局消息
$。每个(b,函数(c,d){
a、 渲染消息(d);
});
})

因此,您可以在模板标记上这样调用修复文件:

<h:outputScript name="javascript/primefacesFixes.js" target="head" />


并且只能在页面上使用一个
p:growl
来呈现所有需要的消息。

对于那些希望以相同的
p:growl
方式在堆栈上显示消息而不隐藏以前消息的人来说,使用primefaces 5.1的一个简单解决方案是覆盖添加primefacesFixes.js的组件的默认行为文件到类路径,并使用下面的注释行重写该函数:

primefacesFixes.js:

PrimeFaces.widget.Growl.prototype.show = function(b) {
var a = this;
this.jq.css("z-index", ++PrimeFaces.zindex);
//this.removeAll(); //Commenting this line prevents an ajax update tho the <p:growl> from erasing global messages
$.each(b, function(c, d) {
    a.renderMessage(d);
});
PrimeFaces.widget.Growl.prototype.show=函数(b){
var a=此;
css(“z-index”++PrimeFaces.zindex);
//this.removail();//注释这行可防止ajax更新通过删除全局消息
$。每个(b,函数(c,d){
a、 渲染消息(d);
});
})

因此,您可以在模板标记上这样调用修复文件:

<h:outputScript name="javascript/primefacesFixes.js" target="head" />


并且只能在页面上使用一个
p:growl
来呈现所有需要的消息。

在一个旧问题上发布此消息,但这可能是一个解决方案(尽管我使用的是PFv6.2):



只需将
keepAlive=“true”
添加到咆哮元素。

在一个旧问题上发布此内容,但这可能是一个解决方案(尽管我使用的是PFv6.2):


只需将
keepAlive=“true”
添加到咆哮元素

<p:growl id="messages" showDetail="true" keepAlive="true"/>