This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

kommunication between beans  RSS feed

 
Mimi Cha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,
i am new in the jsf programming. I don't know, what should i do, so that two beans can 'talk to each other'- I mean, a bean can use a method or attribute of the other.
Thanks in advance for you help.

mimi
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that beans are basically ordinary java objects, so to talk to each other, they probably should have references to each other.

Are those managed beans you are talking about?
 
Mimi Cha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,they are both managed beans.
they are visible/useable for all jsp pages, but not for the other bean. It works only when i creat a bean with" myBean bean=new myBean();" then i can refer to the attribute of this bean. I think, it is not a good idea.
 
Fintan Conway
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mimi Cha:
Hallo,
i am new in the jsf programming. I don't know, what should i do, so that two beans can 'talk to each other'- I mean, a bean can use a method or attribute of the other.
Thanks in advance for you help.

mimi

Hi Mimi,

The following should help : Bean communication

HTH,

Fintan
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The config-based way given in the previous link is the way to go, IMHO. (Unless you cannot do it because a session bean needs a reference to a request bean -- but that smells bad, eh?) What's nice about the config way is that it's playing by the Dependency Injection rules, which is just a fancy way of saying that, among other things, it makes your code easy to unit test.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!