JSF Central - FAQ
JSF Central

 
 Home 
 
 Products 
 
 Articles & Books 
 
 Resources 
FAQ > Programming with JSF
How do I find a bean stored in one of the application's scopes?
Updated: January 22, 2004

Even though you can access JavaBeans stored in the session, request, or application scopes through normal Servlet API objects like HttpServletSession or HttpServletRequest (which you can get from the ExternalContext object), you should access them through JavaServer Faces' ValueBinding class instead. This allows you to use the managed beans facility, which automatically creates JavaBeans if they don't already exist (assuming they are declared in faces-config.xml). You can do this by getting a ValueBinding instance from the Application class:

                   
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
MyObject myObject = (MyObject)app.createValueBinding("#{myObject}").
                                   getValue(facesContext);

					


RSS feed(all feeds)
RSS feed(Programming with JSF)

The Editor's Desk
Podcasts
Inside Facelets
In the Trenches

Site version 1.83  Report web site problems

Copyright (C) 2003-2015 Virtua, Inc. All Rights Reserved. Java, JavaServer Faces, and all Java-based marks are trademarks or registered trademarks of Oracle Corporation. in the United States and other countries. Virtua, Inc. is independent of Oracle Corporation. All other trademarks are the sole property of their respective owners.