Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initialization of Managed Bean

 
Aioria sun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
Just confused the initialization of the managed bean defined in the face-config.xml file. When does the managed-bean actually initialize? is it based on what scope you define for the bean? Like, request-scoped beans only initialize when they are needed in request? session-scoped beans are initialize when a session is created?( and how a session is created? how to know which session they belongs to?) and application-scoped beans are built when the server start? and Can someone tell me about the life-cycle for these beans? thanks~~
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When does the managed-bean actually initialize


From what I've seen, it's initialized the first time it's needed.

-Cameron McKenzie
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18223
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cameron Wallace McKenzie wrote:
When does the managed-bean actually initialize


From what I've seen, it's initialized the first time it's needed.

-Cameron McKenzie


Correct. Managed beans are created/initialized on demand. Specifically, session and application scope beans are not created when the session or application is first created, but rather when the first attempt to reference them is made in a JSF page request. Which means that if you need these items created in advance, you have to manually construct them in the old-fashioned non-JSF way. Or gimmick up a reference.
 
Jason Irwin
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim! That was going to be one of my questions today.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic