加载页面时显示咆哮声primefaces jsf2 [英] display growl when page is loaded primefaces jsf2
问题描述
我有这个commandButton:
I have this commandButton :
<p:commandButton value="Enregistrer" action="#{reglementClientMB.ajouter}"
process="@this @form" update="@form" >
<f:setPropertyActionListener target="#{reglementClientMB.est_ajouter}" value="false" />
</p:commandButton>
动作方法返回到另一页,我想在加载下一页时显示一个p:growl
the action method return to another page , I want to display one p:growl
when the next page is loaded
我测试过将其作为其托管bean的构造函数,但咆哮声显示在页面中的数据下方
I tested to put that is the constructor of its managed bean but the growl is displayed below data in the page
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_INFO, ""
+ "Confirmation", "Réglement crée avec sucée"));
RequestContext.getCurrentInstance().update("messages");
我该如何实现
先谢谢您
推荐答案
如果<p:growl>
是在第一次构造bean之前呈现的,则bean的构造函数可能为时已晚.例如
The bean's constructor may be too late for the job if the <p:growl>
is rendered before the bean is been constructed for the first time. E.g.
<p:growl />
...
<h:outputText value="#{bean.something}" />
仅当在<p:growl>
呈现之前构造了bean时,该函数才起作用.
It would only work if the bean is constructed before the <p:growl>
is rendered.
<h:outputText value="#{bean.something}" />
...
<p:growl />
为了解决您的具体问题,您需要在预渲染视图侦听器中完成这项工作.
In order to solve your concrete problem, you'd need to do the job in a pre render view listener instead.
<f:event type="preRenderView" listener="#{bean.init}" />
使用:
public void init() {
// Add the desired message here.
}
这篇关于加载页面时显示咆哮声primefaces jsf2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!