Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with managed bean

 
kamel ben Mbarek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i'm new here and i'm trying to learn how to develop using j2ee .. i have encountred a problem when using managed beans . the idea was that i'll make one managed bean for each (xhtml) page but the problem is ; i can't access information contained in one managed bean from another ..

it's a simple login then redirection to home page . so can any body give me a hint on how to save the user information during his session and access them from anywhere class i want .

please help
thank you


p.s i'm using jsf 2.0 on glassfish 2.0 server
 
Abdulkerim inanmis
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yo can acces a session beans from another bean with below code.

MyBean mb = (MyBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("myBean");
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kamel

You can use the option of Abdulkerim is very well, but it suppose that your bean must be a Session Scope, I want to give you another option to make the same thing:

Regards
Cesar
 
kamel ben Mbarek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys for your help. i found this solution using annotation :



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic