Menu

Managed bean that is one per session

Users
2005-06-30
2013-04-08
  • David Tashima

    David Tashima - 2005-06-30

    Hello, I want to have a managed bean that is basically one per session.

    I have it set up so that singleton="false", and so that the jsf scope is "session". But I have two other beans that have it as a dependency - so when everything starts up, I get two separate instances of the bean.

    Is it possible to specify one per session? Or am I hosed?

    Thanks,
    Dave

     
    • Mike Kienenberger

      I'm a novice at this, but does it work correctly if your two other beans also have a scope of "session"?

       
    • David Tashima

      David Tashima - 2005-06-30

      Nope, doesn't work... they are still initializing twice.

      -Dave

       
    • Thomas Jachmann

      Thomas Jachmann - 2005-07-01

      The non-singleton obviously is a spring managed bean. Are the others as well? If so, you might want to reconsider your application design since scopes only apply to JSF and spring beans shouldn't and can't access JSF managed beans. Usually, JSF beans are used for the frontend (needing session scope support) whereas spring beans are used for general application centric processes and tasks, services and such.

      A spring bean accessing another spring bean doesn't access it via the scoped JSF bean and thus gets a new instance each time it requests the bean since it is not a singleton.

      HTH,
      Thomas

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.