Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a bean method before page is rendered?

Tags:

java

jsf

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.

like image 994
Tarun Sapra Avatar asked Apr 20 '11 05:04

Tarun Sapra


2 Answers

In JSF2 you can use system Event also.

<f:event type="preRenderView" listener="#{customerBean.loadData}"/>
like image 50
Suraj Avatar answered Oct 24 '22 03:10

Suraj


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

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

like image 21
jmj Avatar answered Oct 24 '22 02:10

jmj