Simon, Your idea for using the bean that programmatically creates the phase listener seems promising ... maybe a servlet listener that just gets the jsf context and creates the managed bean?
I'm creating an ajax component so what I've done is write out a hidden field that has the value binding in it (this is set as a component attribute). Then when I make the ajax request, I grab that value and send it with the request. The phase listener then programmatically resolves the binding bean (defined in faces-config) and uses it. Don't know if that'll work in your situation... Regards, Matt Simon Kitching-3 wrote: > > Matt Tyson wrote: >> Can you have a phase listener entry in the config.xml be a managed bean >> reference? >> >> I've got a phase listener that needs a reference to another object to get >> some data and I want to externalize that reference. > > Not as far as I know. I would also love this to be possible in order to > pass configuration data to phase listeners but haven't figured out how. > > Of course, you do mean an application-scope managed bean, yes? No other > scope makes sense as phase listeners are global for a webapp. > > It is possible to create a class that registers itself as a > PhaseListener when an instance is created. However if this is listed as > an application-scope managed bean, then it doesn't get created until > something references it from a page. It would be wonderful if there was > some "lazy-init=false" option for application-scope managed beans to > force them to be created on webapp startup but this doesn't exist AFAIK. > > As the app I'm currently working on uses Spring, I declare a Spring > singleton bean which explicitly looks up the Lifecycle, gets the phase > listener list, searches it for an instance of my phase listener type, > then calls setter methods to push the config data defined in the spring > file into the phase listener. Spring singletons are created when spring > is initialised (which is just after JSF is initialised). This > implementation is not terribly clean or intuitive so if anyone has > alternate suggestions I'd be keen to hear them.. > > Regards, > > Simon > > -- View this message in context: http://www.nabble.com/PhaseListener-as-managed-bean--tf2771203.html#a7746342 Sent from the MyFaces - Users mailing list archive at Nabble.com.

