gpt4 book ai didi

jsf-2 - 加载页面时显示 growl primefaces jsf2

转载 作者:行者123 更新时间:2023-12-04 22:47:53 25 4
gpt4 key购买 nike

我有这个 commandButton :

    <p:commandButton value="Enregistrer" action="#{reglementClientMB.ajouter}" 
process="@this @form" update="@form" >
<f:setPropertyActionListener target="#{reglementClientMB.est_ajouter}" value="false" />
</p:commandButton>

action方法返回另一个页面,我想显示一个 p:growl下一页加载时

我测试把它放在它的托管 bean 的构造函数中,但是 growl 显示在页面中的数据下方
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 之前呈现。例如。

<p:growl />
...
<h:outputText value="#{bean.something}" />

仅当 bean 在 <p:growl> 之前构造时才有效。被渲染。
<h:outputText value="#{bean.something}" />
...
<p:growl />

为了解决您的具体问题,您需要在预渲染 View 监听器中完成这项工作。
<f:event type="preRenderView" listener="#{bean.init}" />

和:
public void init() {
// Add the desired message here.
}

关于jsf-2 - 加载页面时显示 growl primefaces jsf2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16550545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com