Search code examples
javajsf-2myfaces

How can I get all the initialized managed beans in the session?


How can I get all the initialized managed beans in the session? Following code crashes the JVM every time.

FacesContext facesContext=FacesContext.getCurrentInstance();
com.sun.faces.application.ApplicationAssociate application = 
ApplicationAssociate.getInstance(facesContext.getExternalContext());

Solution

  • Can't you use something like

     FacesContext context = FacesContext.getCurrentInstance();
     HttpSession session = (HttpSession) context.getExternalContext().getSession(true);
     Enumeration mySessionBeans = session.getAttributeNames();