myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Mehrwald <>
Subject Re: Listener
Date Sun, 24 Aug 2008 19:32:52 GMT
Thank you very much for you help.
Yes, this is what I wanted to do. Indeed I tried to set the attribute to 
the FacesContext because I did not know that the servlet context will 
lead to the application context.
Nevertheless it is working now. Thank you again.


simon schrieb:
> Do you mean that you want code running within a request to be able to
> call
>   FacesContext
>    .getCurrentInstance()
>    .getExternalContext()
>    .getApplicationMap()
>    .get("someKey")
> and get some object that you set up at webapp startup time?
> If so, then that's fairly simple. The getApplicationMap() call above
> just returns all objects that are in the standard servlet application
> scope, ie the values of
>   javax.servlet.ServletContext.getAttribute()
> So just write a ServletContextListener, and call
> ServletContext.setAttribute to store your special object. It is then
> later accessable to jsf as an "application scope" value. Yes, the
> FacesContext doesn't yet exist, but that doesn't matter.
> If you really do need access to the FacesContext for some reason then
> things do get trickier. Matthias' info below is one option; there are a
> couple of others solutions too.
> Regards,
> Simon
> On Sun, 2008-08-24 at 11:49 +0200, Matthias Wessendorf wrote:
>> Even a servlet req listener is to early. Take a look at our  
>> MyFacesServlet how to decorate the FacesServlet.
>> Sent from my iPod.
>> Am 24.08.2008 um 01:34 schrieb Markus Mehrwald <>:
>>> Hello,
>>> is there a Listener available which tells me when the FacesServlet  
>>> is started? I want to put something in the application object map  
>>> but if I use the javax.servlet.ServletContextListener it is to early  
>>> and the the FacesContext seems not to be created by now.
>>> Thanks,
>>> Markus

View raw message