Announcement Announcement Module
Collapse
No announcement yet.
How to handle session scoped bean initialization Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X