I’d like to register/add a Managed Bean class programmatically (from within a Servlet init()) into application scope.
How can I do that with JSF 1.2?
I’d like to register/add a Managed Bean class programmatically (from within a Servlet init())
Share
So, it concerns a non-JSF request. The
FacesContext#getCurrentInstance()would returnnullhere, so it’s of no use for you here.It’s good to know that JSF application scoped managed beans are basically stored as an attribute of the
ServletContext. In theinit()method you’ve theServletContextat your hands by the inheritedgetServletContext()method. So, the following should do:That’s it. It’ll be available in JSF by
#{managedBeanName}.