I've used struts in the past and have a new project that I'd like to do with Seam.
I'm not incorporating hibernate due to my inexperience with it and want to know how to inject a DataSource that's defined in ??-ds.xml in the deploy directory. There are circumstances where I need to access data in multiple databases from the same application so I have more than one defined here.
Assume I have the following defined in the ds.xml file
<local-tx-datasource> <jndi-name>myDatasource</jndi-name> .... </local-tx-datasource>
public class LoginAction implements Login { // What will get my datasource injected here? // I've tried countless variations. @In or @In(value="myDatasource") or ??? private DataSource myDatasource; @In(create=true) private User user; // Session scope public LoginAction() { } public String challenge() { String rtn; if(!user.isAuthenticated()) { // authentication logic here/ query the database to check role/access // if not authenticated set rtn = "invalid" // otherwise store user role/access in user object in session scope // User object should reside in session scope for interrogation on next request. } return rtn; } }
<pages> <page view-id="*" action="#{loginAction.challenge}"/> </pages>
Sorry for posting in the wrong group.
I have posted this in JBoss Seam group at http://www.jboss.com/index.html?module=bb&op=viewtopic&t=86483&start=-10