File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Managed Bean Life cycle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Managed Bean Life cycle" Watch "Managed Bean Life cycle" New topic

Managed Bean Life cycle

Ramaguru Ramasubbu

Joined: Feb 09, 2006
Posts: 4
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
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

If the managed bean is in session scope and both pages are referencing the same bean, the constructor only gets called once.

GenRocket - Experts at Building Test Data
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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.

There is no emoticon for what I am feeling!
I agree. Here's the link:
subject: Managed Bean Life cycle
jQuery in Action, 3rd edition