aspose file tools*
The moose likes JSF and the fly likes Referencing a managed bean object inside another class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Referencing a managed bean object inside another class" Watch "Referencing a managed bean object inside another class" New topic
Author

Referencing a managed bean object inside another class

Gopikrishna Gopal
Greenhorn

Joined: Sep 08, 2011
Posts: 26
I am instantiating a session scoped managed bean in another managed bean. But I want to reference the object in another java class. Like call the objects method.
How to do it. Please show with some code example. Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

JSF is about Inversion of Control and Managed Beans. So normally you would not instantiate beans of session scope or any other scope inside of a JSF managed bean. Instead, you'd define the session scope bean as a managed bean and inject it as a managed-property into the target bean using either faces-config.xml or the equivalent JSF2 annotations.

One of the virtues of IoC is that the wiring together for 2 beans is all done via basic POJO set/get methods which are invoked by the JSF bean manager according to faces config rules that you specify.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Referencing a managed bean object inside another class