• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Managed Bean Life cycle

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic