This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Need to get the current Instance of one backing bean into another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Need to get the current Instance of one backing bean into another" Watch "Need to get the current Instance of one backing bean into another" New topic
Author

Need to get the current Instance of one backing bean into another

Ben Simon
Greenhorn

Joined: Feb 01, 2011
Posts: 3

I have an editorBean:



And the other bean is also managed and has a method called htmlTable that takes no parameters but returns String type. Now what I want to do is when my editor pops up it should pre populate itself with some table data and then become part of the value attribute in the editor bean. I think it needs to be done with DI but I am not getting it right. If any one can explain this through DI annotations, it would be cool.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Sure. Welcome to the JavaRanch!

If you're using annotations, the @ManagedBean annotation will ensure that the bean is constructed automatically in the scope that you specified in you "@xxxxScoped" annotation and it's cataloged by default under the same name as the managed bean's class, except that the first character will be lower-case (since it's an instance of the class and not the class itself).

You can then use the @ManagedProperty annotation to inject Bean2 into Bean1 (for example).

It looks like this:




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: Need to get the current Instance of one backing bean into another
 
Similar Threads
How To Create This Drop-Down List
Populate JavaBean With Data Fetched From the Database
Struggling With Passing Data Between Data Access Class, Business Bean, and Controller
Retrieve the Value of a Bean Property in a Servlet
Reference a Non-static interface in a static Method