File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Initialization of Managed Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Initialization of Managed Bean" Watch "Initialization of Managed Bean" New topic
Author

Initialization of Managed Bean

Aioria sun
Greenhorn

Joined: Jun 03, 2009
Posts: 4
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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Jun 25, 2001
Posts: 15964
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
Thanks Tim! That was going to be one of my questions today.


SCJP6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Initialization of Managed Bean
 
Similar Threads
Injecting a session bean into an application bean
Question about bean creating
Why is my faces-config.xml session bean not appearing in the session?
Context mapping between backing/managed beans
Forcing managed bean into session scope