admin管理员组文章数量:1357281
I recently migrated my JSF application to Spring Boot 3 and Jakarta EE, and now I’m experiencing an issue where my preRenderView() method gets called twice per page load, in different threads. This is causing problems when trying to show FacesMessages on the page, as they get loaded into the FacesContext MessageList the first time, but then preRenderView is called again and the messages are lost.
I call the preRenderView method in my AbstractController from all controller JSF pages like this inside a <ui:define>
element that I insert into the template.
<f:event listener="#{controller.preRenderView()}" type="preRenderView" />
My preRenderView calls this method:
public void showMessages()
{
if (FacesContext.getCurrentInstance().getResponseComplete())
{
return;
}
final var messages = Optional
.ofNullable((List<FacesMessage>) FacesContext.getCurrentInstance()
.getExternalContext()
.getSessionMap()
.remove("flash.messages"))
.orElse(Collections.emptyList());
for (final FacesMessage message : messages)
{
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
All my controllers have the Spring Context @Scope("view")
annotation.
FacesContext.getCurrentInstance().getResponseComplete()
and FacesContext.getCurrentInstance().isPostback()
are always false, so I couldn't fix it using these checks.
Before the upgrade to Spring Boot 3 this code worked just fine.
本文标签: JSF preRenderView() Called Twice in Different Threads After Migrating to Spring Boot 3Stack Overflow
版权声明:本文标题:JSF preRenderView() Called Twice in Different Threads After Migrating to Spring Boot 3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744033544a2579353.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论