JSF F:事件preRenderView为f触发:Ajax调用和部分呈现,其他的东西? [英] JSF f:event preRenderView is triggered by f:ajax calls and partial renders, something else?

查看:631
本文介绍了JSF F:事件preRenderView为f触发:Ajax调用和部分呈现,其他的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,我们有一个f:事件:

So we have an f:event:

   <f:metadata>
    <f:event type="preRenderView" listener="#{dashboardBacking.loadProjectListFromDB}"/>
   </f:metadata>

这是引发根据需要对初始页面加载(渲染)。

Which is triggered as desired on initial page load (render).

然而,这preRenderView事件也是由一个Ajax部分页面触发渲染,从而重新呈现的H:panelGroup中与ID projectListing,如下图

However this preRenderView event is also triggered by an ajax partial page render, which re-renders an h:panelgroup with the id projectListing, as below.

<h:commandButton action="#{mrBean.addProject}" value="Create Project"
                                     title="Start a new project">
   <f:ajax render="projectListing" />
</h:commandButton>

我只希望dashboardBacking.loadProjectListFromDB被调用的初始页面呈现,而不是当有一个Ajax局部渲染。有没有我可以用更合适的事件或方法?

I only want the dashboardBacking.loadProjectListFromDB to be called for the initial page render, but not when there is an ajax partial render. Is there a more appropriate event or method I could be using?

推荐答案

另一种选择是把你的 preRenderView 功能在一个 ViewScoped 的@PostConstruct 法管理的bean。当bean被初始化这个逻辑会被执行,而你保持你的Bean进行,直到你改变看法所有Ajax请求的同一个实例。

Another option would be to put your preRenderView functionality in a @PostConstruct method of a ViewScoped managed bean. This logic would be executed when the bean is initialized, and you you maintain the same instance of the bean for all your ajax requests until you change views.

这篇关于JSF F:事件preRenderView为f触发:Ajax调用和部分呈现,其他的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆