-
1. Re: No facesContext present on session-startup in SeamTest
pmuir Oct 6, 2008 4:22 PM (in response to toby.tobias.hill.gmail.com)Yeah, file a feature request in JIRA.
-
2. Re: No facesContext present on session-startup in SeamTest
toby.tobias.hill.gmail.com Oct 7, 2008 7:36 AM (in response to toby.tobias.hill.gmail.com)Ok, here it is: JBSEAM-3524
-
3. Re: No facesContext present on session-startup in SeamTest
tazman Oct 7, 2008 10:12 PM (in response to toby.tobias.hill.gmail.com)I have a bigger issue with Seam 2.1.0.CR1: facesContext is always null no matter if it is SeamTest or not. Here is my code (was working with 2.1.0.BETA1)
@Name("sessionStartup") @Scope(ScopeType.SESSION) @Startup public class SessionStartup { @In FacesContext facesContext; ...
I also tried FacesContext.getCurrentInstance(), but it too returns null.
-
4. Re: No facesContext present on session-startup in SeamTest
torakuma Oct 27, 2008 6:45 PM (in response to toby.tobias.hill.gmail.com)I also have this problem as I need the facesContext on a Startup component. I need this since I write files to a served directory and I want to clear it out when the app starts (I need facesContext to call getRealPath(/somepath).
Has anyone found a temporary workaround for this?
Thanks!
D
-
5. Re: No facesContext present on session-startup in SeamTest
toby.tobias.hill.gmail.com Oct 28, 2008 8:59 AM (in response to toby.tobias.hill.gmail.com)Well I get the feeling you should have posted your query on the other thread. This thread is just about the problem in SeamTest compared to in JBoss AS and has been there before the 2.1.0.GA release. The other thread describes that JBoss AS now too does not provide a facescontext on session startup.
As for the workaround:I guess you can use the same approach. Set up a ServletFilter (as part of seam's filter wrapper or in front of the seam servlet itself). In that filter what you need should be available and can be stored in a ThreadLocal for later use by the same thread (i.e. when your Session starts).
To be specific in your case:public void init(FilterConfig conf) throws ServletException { // here it is conf.getServletContext().getRealPath() }
I have not tried this (I wrote it from the top of my head really) ... I guess it should work. Save the servlet context in the TL.
-
6. Re: No facesContext present on session-startup in SeamTest
torakuma Oct 29, 2008 3:27 PM (in response to toby.tobias.hill.gmail.com)Wow I never would have thought to use a ThreadLocal in a filter! Thanks for the tip.
Kinda scary doing it this brute-force way though. Hopefully in the future they will fix it and provide a facesContext on startup.
Thanks again-
D