-
1. Re: Seam 2.1 issue: httpServletRequest null within a Create-method
toby.tobias.hill.gmail.com Oct 24, 2008 2:19 PM (in response to toby.tobias.hill.gmail.com)To be precise: It is really the FacesContext that does not exist at the time when the @Create-annotated method on a session scoped component is started (@Startup).
-
2. Re: Seam 2.1 issue: httpServletRequest null within a Create-method
tazman Oct 24, 2008 2:20 PM (in response to toby.tobias.hill.gmail.com)As I wrote in your other topic previously, this doesn't work since Seam 2.1.0.CR1 either:
@Name("sessionStartup") @Scope(ScopeType.SESSION) @Startup public class SessionStartup { @In FacesContext facesContext; ...
facesContext is always null!
-
3. Re: Seam 2.1 issue: httpServletRequest null within a Create-method
toby.tobias.hill.gmail.com Oct 24, 2008 2:25 PM (in response to toby.tobias.hill.gmail.com)Nice to know that I am not alone then. :)
Well, I managed to workaround it for now:
A HttpFilter picks up the incoming request and response objects and store those on static ThreadLocals. Where I need them (at startup of the mentioned component for instance) I just fetch them from this structure.Ugly, but works.
-
4. Re: Seam 2.1 issue: httpServletRequest null within a Create-method
tazman Oct 24, 2008 2:29 PM (in response to toby.tobias.hill.gmail.com)Funny that I was thinking about to implement the same workaround as yours, using filters and ThreadLocals :-)
-
5. Re: Seam 2.1 issue: httpServletRequest null within a Create-method
yahawari May 28, 2009 4:05 AM (in response to toby.tobias.hill.gmail.com)i ran into the same problem ( Seam 2.1.1 and JBOSS AS 4.3). However, my seam component observes the built in
org.jboss.seam.security.loginSuccessful
event. The function i have tries to access facesContext, which is always null!.@In FacesContext facesContext; @Observer("org.jboss.seam.security.loginSuccessful" ) public void func(){ if(facesContext != null){ HttpSession currentSession =(HttpSession)facesContext.getExternalContext().getSession(false); currentSession.setMaxInactiveInterval(7200); } }
i executed a page action and tries to access facesContext. strangely, facesContext is NOT null.
so Component functions that are executed in response to an event do not have access to faces Context i.e. FacesContext.getCurrentInstance().
it makes sense somehow since seam observer functions are not a part of the JSF cycle.
is there another way to access HttpSession, RequestSession in seam applications ??