我有以下命令按钮和咆哮组件:
<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"/>
我添加了一条面孔消息,如下所示:
@ManagedBean
public class MessageControler {
public void eventAdded(){
FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"Rezerwacja została dodana",null));
}
}
但是,它不会出现在growl组件中。这是怎么造成的,我该如何解决?
答案 0 :(得分:1)
我的以下最小示例有效,您可能会检查commandButton
<!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>
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));
}
}