Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force a managed bean to initialize first?

Tags:

jsf

I have a navigation managed bean for each user.

and I need it to initialize first before any other bean because a value is required from the bean.

May I know how do I perform that?

I have tried eager="true" but it doesn't work.

any quick and easy solution via faceconfig would be greatly appreciated.

like image 399
seesee Avatar asked Dec 05 '25 23:12

seesee


1 Answers

Just perform the desired initialization job in bean's @PostConstruct.

@PostConstruct
public void init() {
    // Here.
}

It'll be invoked when the bean is injected/referenced from another bean for the first time.

The eager=true works only on application scoped beans.

like image 79
BalusC Avatar answered Dec 07 '25 17:12

BalusC