If I'm following you here, then you'd have a phase listener (call it
'listenerLoader') that basically instantiates the managedbean that will in
turn become a phase listener itself?
Seems like it should work...
Mike Kienenberger wrote:
>
> What about creating a normal application-scoped managed bean to store
> your configuration and then manually fetching a reference to it using
> a value binding in the phase listener?
>
> To borrow Jeff's example:
>
> FacesContext context = FacesContext.getCurrentInstance();
> ValueBinding binding =
> context.getApplication().createValueBinding("configBean");
> return (ConfigBean)binding.getValue(context);
>
>
> On 12/7/06, Simon Kitching <[EMAIL PROTECTED]> 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#a7746386
Sent from the MyFaces - Users mailing list archive at Nabble.com.