Hello, I am using Seam 1.0.0.CR1. I am having some difficulty with the @In and @Out annotations. I will explain my 'use case' then I will explain the problem.
I am developing a prototype Seam web application that is integrated with the CAS http://www.ja-sig.org/products/cas/ Single Sign-On system. What this means is that I am deploying a Filter along with my application that works out the authentication status of the user with the CAS server. Once the the Filter has established that the user is authenticated, it let's the user's requests proceed on to the Seam (web) application that it fronts. Once I get to the first page in my Seam, I would like to use a component (a POJO style STATELESS component (not EJB3)) to perform a hibernate query and return some user-specific data. I read in the documentation that I should create a pages.xml file and add something like the following: | <pages> | <page view-id="/main.xhtml" action="#{conversation.begin}"/> | </pages> | so I added this (main.xthml is the page that renders in response to requests for /main.seam). I have snipped the only 'interesting' code from main.xhtml here: | Welcome #{aNumber} (aNumber)<br/> | Welcome #{remoteUser} (remoteUser)<br/> | Welcome #{com$evergreen$sso$SSOData.userPrincipal} (ssoData.userPrincipal)<br/> | Welcome #{com$evergreen$sso$SSOData.userPrincipal.userid} (com$evergreen$sso$SSOData.userPrincipal.userid)<br/> | Welcome #{com$evergreen$sso$SSOData.userPrincipal.personName} (com$evergreen$sso$SSOData.userPrincipal.personName)<br/> | .... | Conversation.id = #{conversation.id}<br/> | #{userLinks} | which results in a display like the following: | Welcome (aNumber) | Welcome (remoteUser) | Welcome EvergreenSSOPrincipal{userid=A42........} (ssoData.userPrincipal) | Welcome A42.... (com$evergreen$sso$SSOData.userPrincipal.userid) | Welcome B .... Smith (com$evergreen$sso$SSOData.userPrincipal.personName) | where the stuff from com$evergreen$sso$SSOData is supplied in the HttpSession via the Filter class I deployed with the application. The first problem here is from #{userLinks}. I have tried to bind this to this bean: | @Name("userLinkActions") | @Scope(ScopeType.STATELESS) | public class UserLinkActions { | | private Log log = LogFactory.getLog(UserLinkActions.class); | | @In(required = true) | private Context sessionContext; | | @In(value="#{userPrincipal}",required=true) | private EvergreenSSOPrincipal ssoPrincipal; | | @In(create=true) | private Session appssoDB; | | @In(create=true) | private FacesMessages facesMessages; | | @Out(scope=ScopeType.SESSION) | private User user; | | @Out | private Collection<Link> userLinks; | | public UserLinkActions() {log.info("new UserLinkActions()");} | | @Factory("userLinks") | public final void getUserLinks() { | log.info("getUserLinks() - (in) user = " + user); | log.info("getUserLinks() - (in) ssoPrincipal = " + ssoPrincipal); | log.info("getUserLinks() - (in) appssoDB = " + appssoDB); | log.info("getUserLinks() - (in) sessionContext = " + sessionContext); | log.info("getUserLinks() - (in) facesMessages = " + facesMessages); | | if (ssoPrincipal == null) { | log.info("Yikes! getUserLinks() - ssoPrincipal is null."); | userLinks = new ArrayList<Link>(); | return; | } | final User currentUser = (User)appssoDB.createQuery("from User where aNumber=:aNumber") | .setParameter("aNumber",user.getaNumber()) | .uniqueResult(); | log.info("getUserLinks() - (out) currentUser = "+currentUser); | userLinks = currentUser.getLinks(); | if (userLinks != null) { | log.info("getUserLinks() - user has "+userLinks.size()+" links."); | } | } | | } | The server console reports the following when /main.seam (/main.xhtml) is reached: | 15:46:21,934 INFO [User] new User() | 15:46:21,997 INFO [UserLinkActions] new UserLinkActions() | 15:46:21,997 INFO [UserLinkActions] getUserLinks() - (in) user = null | 15:46:21,997 INFO [UserLinkActions] getUserLinks() - (in) ssoPrincipal = null | 15:46:21,997 INFO [UserLinkActions] getUserLinks() - (in) appssoDB = null | 15:46:21,997 INFO [UserLinkActions] getUserLinks() - (in) sessionContext = null | 15:46:21,997 INFO [UserLinkActions] getUserLinks() - (in) facesMessages = null | 15:46:21,997 INFO [UserLinkActions] Yikes! getUserLinks() - ssoPrincipal is null. | Please disregard the hibernate query in the bean based on the User property - I know that won't work in its current state. I am trying to understand why the @In annotations aren't behaving as I expect. I am sure I once again missed something in the documentation, the configuration, are in this forum (yes I have searched and read). I am mainly concerned that the objects, components, parameters I would like injected are not being injected. Help! Any help is appreciated. Thanks. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3940261#3940261 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3940261 ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
