Hi Michael,
In CDI you would get a proxy injected on the basis of your current 
request. So in this case every user would get their own FacesContext.
Regards,
Manfred
On 10/6/14, 5:04 PM, Michael Müller wrote:
>
> Am 06.10.2014 22:16, schrieb manfred riem:
>> Hi Michael,
>>
>> Answers inline
>>
>> Regards,
>> Manfred
>>
>> On 10/6/14, 3:08 PM, Michael Müller wrote:
>>> Hi Manfred,
>>>
>>> I assume this shall work with any other context too? I'm thinking 
>>> especial of a custom defined context.
>> Injection would work into any CDI managed bean within the limits set 
>> by the CDI specification.
>>
>>> And thinking of @SessionScoped or beans with a longer lifecycle: 
>>> During a session I might call a non-Faces Servlet, for example an 
>>> upload bean (although JSF offers upload, I prefer a JavaScript 
>>> controlled upload by XMLHttpRequest or iFrame to show a progress 
>>> bar, cancel button, and more). And I need to access some other 
>>> backing beans. It would be much easier to perform such an access if 
>>> it would be possible to inject a FacesContext in such a Servlet. 
>>> Although there is no call to the Faces Servlet, I guess it would be 
>>> possible to inject the same context as available for a 
>>> @SessionScoped bean.
>> Unfortunately it actually would not as the non-Faces servlet does not 
>> setup the FacesContext.
> Yes, that is true. But which FacesContext would you inject into a 
> @SessionScoped bean? As far as I know, the context is build with every 
> request to the FacesServlet. Usuall, you can't inject a bean with a 
> shorter lifecycle into one with a longer one. I assume, the injected 
> variable will preserve the initial context or it's contend will be 
> renewed with every request? Anyhow, it is longer accessible than a 
> single request. And my idea is to inject it into a different servlet 
> of the same session (if context is preserved). If the content of the 
> injected field is internally renew with every request, than it woul be 
> usefull to create something similar to a faces context.
>
> Accessing the session map via 
> httpUtil.getRequest().getSession().getAttribute(xxx) is possible, but 
> it would be more convenient to access it similar to 
> FacesContext.getCurrentInstance().getExternalContext().getSessionMap(). Or 
> to provide a more simpler way to access the application, and, and, and.
> Not a real FacesContext, but something with a similar behavior. Got my 
> point?
>
>>> Herzliche Grüße - Best Regards,
>>>
>>> Michael Müller
>>>
>>> Web Development with Java and JSF: https://leanpub.com/jsf
>>
>