1 Reply Latest reply on Sep 16, 2009 11:51 AM by paul.williams

    Maintaining state

    chris12296

      I have an app that starts with a login screen and once a user is logged in they proceed to a welcome screen.  My app is set up based on the Cairngorm microarchitecture.  When the app loads it dispatches an event to get the "currentUser" property from an ejb3 stateful bean and if this "currentUser" property is null (the user hasnt logged in yet), the user must login.  If it is not null (the user has previously logged in), the user is taken to the welcome screen.  Once the user logs in, the currentUser property is set on the stateful bean so they wont have to log in again until the session expires.

       

      That is how I want it to work, but if you refresh the browser, you are taken back to the login screen.  It seems that the Java EJB Container doest know its the same client so a new stateful bean is created everytime the browser is refreshed.  I am wondering what is the best way to go about remembering the login and what screen they were on, in case the browser is refreshed before they logout.  And I would also like to know how to use stateful beans with flex and blazeds.

        • 1. Re: Maintaining state
          paul.williams Level 4

          I think it is more common to use the HttpSession to track users between

          requests in a presentation tier. I've never tried to manage a user

          session with a stateful session bean, but I'm guessing that each time

          the client makes a request, you are creating a new blank stateful

          session bean. If you want to track the user between requests you will

          need to store the session bean between requests. You could do this by

          adding the session bean reference to the HttpSession.

           

          Alternatively you could add the 'currentUser' property to the

          HttpSession and use a stateless session bean for login.