当我在页面之间切换时,如何使Primefaces咆哮消息可见



我有一个带有Primefaces咆哮的JSF页面。我想在页面之间切换时使消息可见。这可能吗?

在第二个页面的bean的@PostConstruct方法(或构造函数)中,添加FacesMessage,例如:

context.addMessage(null, new FacesMessage("Growl Message", "Growl Message Text"));  

这是我的解决方案。在重定向之前,它将在当前页面中显示消息。

HTML:

<h:form prependId="false">
    <p:growl />
    <p:button outcome="gotoABC" id="rdr-btn" style="display: none;" />
    <p:commandButton action="#{bean.process()}" update="@form" />
</form>

Bean:

public void process(){
    addInfoMsg(summary, msgDetail); //Add msg func
    RequestContext.getCurrentInstance().execute("setTimeout(function(){ $('#rdr-btn').click(); }, 3000);"); // 3 seconds delay. I put the script in Constants to config later.
}

最新更新