File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes problem with managed bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "problem with managed bean" Watch "problem with managed bean" New topic

problem with managed bean

kamel ben Mbarek

Joined: Apr 20, 2011
Posts: 4
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

Joined: Apr 20, 2011
Posts: 2
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

Joined: Dec 25, 2010
Posts: 90

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:


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
kamel ben Mbarek

Joined: Apr 20, 2011
Posts: 4
thank you guys for your help. i found this solution using annotation :

I agree. Here's the link:
subject: problem with managed bean
jQuery in Action, 3rd edition