简体   繁体   中英

How to execute a bean method before page is rendered?

What is the best approach to execute a method in a bean before the JSF page using that bean is rendered?

Update : I am trying to execute a method which would populate some data used by the JSF backing bean. This backing bean is used in a form on a JSP page, where I need some prepopulated data.

在JSF2中,您也可以使用系统事件。

<f:event type="preRenderView" listener="#{customerBean.loadData}"/>

Constructor of bean / post construct @PostConstruct methods will do it.

But the best approach is greatly depends on the functionality you are implementing ,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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