autoUpdate 不适用于primefaces 中的p:growl 和p:messages

a.u*_*u.r 2 primefaces jsf-2

我正在尝试使用属性 autoUpdate 测试 p:growl 和 p:messages,但它不起作用,尽管这是一个非常简单的代码。

我的页面(primes.xhtml):

<h:head/>
<h:body>
    <h:form>
        <p:messages autoUpdate="true"/>
        <p:commandButton action="#{dateBean.testErr}"/>
    </h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud)

DateBean 类:

@ManagedBean
public class DateBean {

    public String testErr(){

        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, new FacesMessage("test error"));
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

每当我点击 commandButton 时,服务器都会给我以下警告:

“警告:有一些未处理的 FacesMessage,这意味着并非每个 FacesMessage 都有机会被渲染。这些未处理的 FacesMessage 是:-测试错误”

但是消息不会显示在页面中,咆哮也不显示。

小智 5

最新的: Primefaces 7 不支持这个 p:growl 和 p:messages autoUpdate="true"属性。只是它不起作用,您会收到上面的服务器警告:“警告:有一些未处理的 FacesMessages,...”

使用这个而不是 autoUpdate="true" 属性:

<p:messages>
    <p:autoUpdate />
</p:messages>
Run Code Online (Sandbox Code Playgroud)

和这个

<p:growl id="growl" showDetail="true" sticky="true">
    <p:autoUpdate />
</p:growl>
Run Code Online (Sandbox Code Playgroud)

也可以看看: