Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Managed Bean Life cycle

 
Ramaguru Ramasubbu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Just wondering when does an object for the managed bean with session scope get created.
If I have 2 jsp pages and both of the uses the same bean(with session scope), does the constructor of the managed bean called twice?
For example I have a page which has 2 Frames. And the jsps of both the Frame refer to the diffrent properties of the same bean. How many times the constructor of the bean is called?
And How to get and set the current value of one bean's property from the other bean?

Thanks in advance
Ramaguru
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the managed bean is in session scope and both pages are referencing the same bean, the constructor only gets called once.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for the second half of your question, it's common to "inject" one bean into another in the config file:

This is like writing:

so in your Java code, the orange object is able to send messages to the apple object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic