Hello, I have an application-scoped managed bean that takes quite a while to initialize and I would like for it to be initialized at startup time instead of the first loading of the page that uses it. I use tomcat. I know there is no straightforward declarative way to do it see(http://www.jsfcentral.com/editorial/jsf2_wishlist_1.html) but I nevertheless wish for a programmatic way of achieving this perhaps using a servlet. Can anyone help? Thanks in advance, Julien Martin.
Joseph Miller
Greenhorn
Joined: Jun 19, 2001
Posts: 21
posted
0
Julien,
I stumbled across this blog post and wonder if it could help you. It describes how you can get to FacesContext when you're not within the context of JSF: blog post here Once you have an instance of FacesContext, you can initialize the managed bean with EL:
One way to call this code on startup would be to place it in a servlet's init() method and deploy the servlet with the <load-on-startup> attribute.
hope that helps.
-- Joe
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 383
posted
0
Hello Joseph,
The problem is that I call the following method in the managed bean:
and that the facescontext or the externalContext appear to be null even though I specified that the facesservlet should be initialized first.
I have an init servlet try to put the managed bean into the servletcontext.
I always get a nullpointerexception on the line marked npe.