p:growl does not show global faces message

让人想犯罪 __ 提交于 2020-02-07 07:45:08

问题


I've the below command button and growl component:

<p:commandButton id="reservationAdd" actionListener=" {reservationBean.addReservation()}" value="Dodaj" oncomplete="PF('wdlgAddReservation').hide();"  update=":frm" action="#{linkedTimelinesController.createTimeline()}"> 
    <f:ajax execute="reservationAdd" onevent="click" listener="#{messageControler.eventAdded()}"  render="dynamic"/>
</p:commandButton>

<p:growl id="msj" autoUpdate="true"/>  

I'm adding a faces message as below:

@ManagedBean
public class MessageControler {

    public void eventAdded(){  
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"Rezerwacja została dodana",null));  
    }
}

However, it does not show up in the growl component. How is this caused and how can I solve it?


回答1:


My following minimal example works, perhaps you check the attributes of your commandButton

page.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <f:view>
        <h:head/>
        <h:body>
            <h:form>
                <p:commandButton value="Growl">
                    <f:ajax listener="#{page.triggerEvent}"/>
                </p:commandButton>

                <p:growl autoUpdate="true"/>
            </h:form>
        </h:body>
    </f:view>
</html>

Page

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

@ManagedBean
public class Page {

    public void triggerEvent() {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Test!", null));
    }
}


来源:https://stackoverflow.com/questions/30093254/pgrowl-does-not-show-global-faces-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!