Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF - Managed Bean to Managed Bean Communication  RSS feed

 
Sandeep Dwivedi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to transfer the attribute values from one managed bean to anather managed bean, Could anyone please let me know how to accomplish this?

I want to transfer a list attribute value of ActivePackagesMB.java Managed bean to anather managed bean.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several ways. Here are some in the order of my personal preference:

1) Inject the another managed bean as a property of the one managed bean and just use it. Here is an example.

2) Obtain the another managed bean by FacesContext and set it as a property. Here are some ways.

3) Pass it through the session map which you obtain using ExternalContext#getSessionMap(). Let the one bean put the desired value in it and let the other bean get it. Here is an example.
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An alternative way -



Advantages of using this approach is that it will automatically "resolve" the scope of the managed bean that you are after. Of course, you can perform introspection using without actually having to get the actual managed bean.

Regards.
 
Sandeep Dwivedi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys! I highly appreciate your help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!