sessions and vaadin

Hey guys,

Here’s my problem:

I want the user data to be stored in the session so i can use it in my application anywhere and because the application has multiple users.

I have seen a lot of examples relating the user sessions in vaadin some of it says to use threadLocal if i want to use the user data to be stored in the session, but what i think is that using the threadLocal will put real burden on the server…this was the threadLocal part

Some other examples, almost all of them told me to use HttpServletSession, using doGet, doPost methods, what i don’t get is How to use it…

I’ve tried to use it but failed to do so, so please somebody help me with this problem.

Thnx in advance

Your Application instance and all its components etc. are stored in a session. So storing user data to a session is nothing more than keeping a reference to your objects in e.g. your Application. But that doesn’t do anything for persistence or for sharing these between users, so I must misunderstood something in your question.

Thanks Johannes for your reply,

Ok let me tell you my exact problem:

I am creating an application for a clinic in which there are different user roles, e.g. doctors, nurses, patients etc. Now the patient and nurse can both edit the patient data using a GUI, and can also edit the same patient. The problem is that, suppose a staff logs in first and starts editing a specific patients data, at the same time nurse logs in and selects different patient for the data editing…what’s happening in the project is that the staff’s selected patient ID is overridden by the nurse selected patient ID. Now whatever the staff changes in his patient’s data gets saved in the nurse selected patient. This is happening because of the overridden patient.ID,

What i think the solution is that put the data of the logged in user in the session as well as the patient ID so when editing the data only the relevant data is changed…this is where im stuck…

Looks like you are misusing static fields. If the two patients where actually separate objects, there shouldn’t be a problem.