简体   繁体   English

仅对特定页面执行managedBean方法

[英]Execute managedBean method only for a specific page

For a page, I need to initialize potentially a huge list of object. 对于页面,我需要初始化一个巨大的对象列表。 For now, I populate this list in a @PostConstruct method 现在,我在@PostConstruct方法中填充此列表

Is it possible to execute a method only on a specific page? 是否可以仅在特定页面上执行方法?

Or is there a JSF tag to simply execute a method and nothing more ? 或者是否有一个JSF标签来简单地执行一个方法,仅此而已?

It's not an important issue for me but there must be a solution. 这对我来说不是一个重要的问题,但必须有一个解决方案。

I'm using JSF 2. 我正在使用JSF 2。

You may add this to your page: 您可以将其添加到您的页面:

<f:event type="preRenderView" listener="#{backingBean.desiredMethod()}" />

This will execute the desiredMethod() before the RenderView lifecycle phase. 这将在RenderView生命周期阶段之前执行desiredMethod()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM