There is a question I have been wrestling with about whether Seam should make its contextual data directly available in HttpSession and HttpRequest attributes with the same name as the context variable, or whether it should keep stuff separate as it does presently (as you can see).
I think your usecase is quite reasonable; we need to allow people to set up some variables in a servlet filter.
For now, a (very) hacky temporary workaround is to use:
session.setAttribute( ScopeType.SESSION.getPrefix() + '$' + "loggedInUser", user );
Please complain about this problem in JIRA, and I will give it some more thought. TIA
My view is that scope is an aspect that should not be explicitly encoded in an application. We need the jboss microcontainer metdata repository notion (http://wiki.jboss.org/wiki/Wiki.jsp?page=JBoss5RepositoryClasses, http://www.jboss.com/index.html?module=bb&op=viewtopic&t=73653) woven throughout the jboss layers.
The potential point of conflict is whether use of a standard legacy accessor like HttpServletRequest.getParameter("user.home") should suddenly be treated as a heirarchical variable that can be overriden by an thread local aspect, as well as have a default value coming from less dynamic scopes (deployment configuration, system property, server defaults, admin domain defaults, etc.).
I see from JIRA that this issue has been resolved.
Can somone tell me the correct way to make an object directly available to the Http Session so that it can be accessed by a Servlet filter?
@Out(value="loggedInUser", scope=ScopeType.SESSION) private User loggedInUser;
And in my servlet:
user = (User)req.getSession().getAttribute("loggedInUser");
...which returns null. Should this work?
Yes, this should work. (And I'm pretty sure it does. Step through Seam code in your debugger to confirm for yourself.)