[jboss-user] [JBoss Seam] - Injection of Session javabean into event javabean not workin

joeyxxx do-not-reply at jboss.com
Mon May 14 01:02:46 EDT 2007


I'm running 1.2.1 with facelets on JBoss 4.05 EJB3 profile and using pojos not EJBs. This is my first attempt at seam and the ff issue has thrown me for a bit of a loop.
The user component injected into balance is always null and it seams that  I can only reference it is explictly using the ff
 (User) Contexts.getSessionContext().get("user"); 



  | @Name("user")
  | @Scope(SESSION)
  | public class User implements Serializable
  | {
  |    private String userName;
  |    private String password;
  |    private String userRole;
  |    private String segment;
  |    private String firstName;
  |    private String lastName;
  |    private String destination;
  |    
  |    public User(String firstName, String lastName, String userName, String password)
  |    {
  |       this.firstName = "James";
  |       this.lastName = "Bond";
  |       this.password = password;
  |       this.setUserName(userName);
  |       this.setUserRole("Investor");
  |    }
  |    
  |    public User() {}
  | 
  | 


  | 
  | @Name("balance")
  | @Scope(EVENT)
  | public class Balance implements Serializable
  | {
  |    private double totalMarketValue;
  |    private double cash;
  |    private double margin;
  |    private String userName;
  |    @In
  |    private User user;
  |    @Logger Log log;
  |    
  |    public Balance() {
  |     this.setTotalMarketValue(0);
  |     this.setMargin(0);
  |     this.setCash(0);
  |     if(user!=null){
  |         this.setUserName("Balance User:"+this.user.getUserName());
  |     } else {
  | //This always works!!!
  |         user = (User) Contexts.getSessionContext().get("user");
  |         this.setUserName("Null @In "+this.user.getUserName());
  |     }
  |    }
  | 
  | 

Are there any disadvantages to using javabeans instead of EJBs if one doesn't care about transactions etc? Is clustering better with EJBs on JBoss?
Thanks

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045333#4045333

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045333



More information about the jboss-user mailing list