Pfau, Oliver wrote:
Another question...is there a difference is I register a phase listener in my backing bean constructor or in the faces-config.xml
Phase listeners are global for the webapp. When one is registered, it goes into a global list of phase listeners. Every time ANY request is processed by the JSF FacesServlet (that's *every* jsf request), all the registered phase listeners are run. It doesn't matter how they are registered, they still go into the global list. And they stay in that list until explicitly removed. Because of this, it really doesn't make sense to register Phase Listener objects dynamically; they should be set up when the webapp starts. Registering one from a backing bean constructor doesn't seem a good idea at all.
And because a phase listener is global, if it has a hard reference to a particular managed bean, then that bean will of course not be garbage-collected. It really doesn't make much sense for a phase listener to directly keep a reference to a managed bean instance (well, maybe an application-scope one would be ok).
A PhaseListener can obtain the current faces context (which will be specific to the current request) then look up managed beans by name (see the wiki), which does allow you to call a managed bean if you know its name.
I suggest you take a step back, and consider alternatives to a PhaseListener for whatever it is you are trying to achieve; it may not be the right tool.
Regards, Simon

