Results 1 to 2 of 2

Thread: How to handle session scoped bean initialization

  1. #1
    Join Date
    Apr 2007
    Posts
    276

    Default How to handle session scoped bean initialization

    I have a session scoped bean that I have put in my applicationContext. Currently when a user logs in I grab some information (userNumber, companyId, ...). I then call appContext.getBean("myBean") to get an instance of this bean and then populate it. From then on I just assume that it is populated throughout my app (which works fine). What I don't understand is what if I had a session scoped bean that wasn't initialized at the beginning of a session. What is a typical way of initializing it? Everytime I call appContext.getBean("myBean") would I have to make sure it is initialized and if it isn't do it then? I just want to clear this up in my head.

  2. #2
    Join Date
    Aug 2009
    Posts
    16

    Default

    I have a similar approach. I have a session scoped bean, I use it by autowiring it to super class of my controllers.
    I have 3 step login procedure, password, security image and pin. On the password page I do not create session, after that page session is created. When I first access it on security image controller it has the initial values in it that are set in bean class. Autowiring that bean in controller provides me a brand new instance of it at the begining. While going through login steps I put all necessary data into it. Then It is ready to be used for that session.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •