JSF Managed Bean auto-create?

Posted by rat on Stack Overflow See other posts from Stack Overflow or by rat
Published on 2010-01-12T16:07:23Z Indexed on 2010/06/11 11:43 UTC
Read the original article Hit count: 529

Filed under:
|
|
|

Is it possible to have a JSF managed bean be automatically created?

For example I have several session scoped beans. Sometimes it becomes necessary to access these instances in code (rather than just in JSF) this is done by:

PageBean pageBean = (PageBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("pages");

However if no page has already been visited which calls to '#{pages}' this resolves to null ... is there anyway to get JSF to create a bean when the scope 'begins'? So in this case ideally when a user session begins the 'pages' bean would be instantiated in the session immediately?

© Stack Overflow or respective owner

Related posts about java

Related posts about jsf