简体   繁体   中英

Invoke managed bean initialization in template

I am wondering if there is a way to call a managed bean method before render response. I have components that depend on a managed bean property but that property needs to be populated before the render response. Normally, I have been using @PostContruct method to initialize my bean and everything is good. This time I have a rare situation where I need the template to pass a value to the bean before anything else happens.

I have JSF 2.2.12 and Tomcat 7. I tried the f:viewAction but that tag will not fire the bean method. It doesn't work at all.

This is what I have for viewAction.

<f:metadata>
    <f:viewAction action="#{cmsUtil.loadPageAssignments('50|27|1|21|2|52|53|23|24|25|28|29|30|31|32|33|17|26|18')}"/>
</f:metadata>

Is there any other way to do what I am trying to do?

Looks like viewAction cannot be in template files. Okay, so database config it is then. Thanks.

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