14

嗨,我在 jsf 环境中是新人,我正在尝试更新 primefaces 咆哮,然后从 commandButton 操作重定向到页面。

 <p:commandButton value="Guardar"  action="#{AgendamientoMBean.procesaAgendamientoJ()}" 
 update="growlDetalle" />  

托管 bean 代码

   FacesContext context = FacesContext.getCurrentInstance();
   context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, descripcion, detalle));
   ....
   ....
    return "agp_bandeja_citas_llamadas?faces-redirect=true";

这只会将我重定向到页面,但不会向我显示咆哮消息,我测试了如果将我的方法更改为不返回页面,消息确实会显示..

我试图更新我重定向的页面的咆哮,但我猜那是不可能的。

我认为重定向时我失去了更新功能,因为我现在在新页面中。

有没有办法告诉 jsf 先做更新然后重定向?

希望你能帮助我,提前谢谢

4

3 回答 3

49

消息在重定向期间丢失。您可以使用闪光灯来保存消息。

在从您的操作方法返回之前添加以下内容:

FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getFlash().setKeepMessages(true);
于 2012-03-29T20:00:55.780 回答
1

向您重定向的页面添加另一个咆哮

像这样 <p:growl id="growlmsg2" showDetail="true" sticky="true" autoUpdate="true"/>

于 2014-07-08T07:37:37.470 回答
-1

因为 Flash 有 bug,我的解决方案是制作一个单独的重定向按钮,在显示 msg 后将被点击:

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>

豆:

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.
}
于 2016-11-25T04:23:26.607 回答