How to execute bean method before page display?

What is the best approach for executing a method in a bean before the JSF page is rendered using a bean?

Update . I am trying to execute a method that populates some data used by JSF bean support. This bean support is used in the form on the JSP page where I need some preliminary data.

+6
source share
2 answers

In JSF2, you can also use a system event.

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

The constructor constructor for bean / post @PostConstruct will do this.

But the best approach depends a lot on the functionality you implement,

+4
source

Source: https://habr.com/ru/post/886291/


All Articles