cancel
Showing results for 
Search instead for 
Did you mean: 

session-save class variables question

Former Member
0 Kudos

Hi,

Im experiencing some strange behaviour. I have an application, which per logged-in user in portal, receives a list of assigned tasks to that user. I divide these tasks in different queues and use a hashmap to provide a link between the task and the queue ( taskid as key, queueId as value)

This works nicely only.....When 2 user log into the portal at the same time, it seems to mix up tasks. I store the maps and lists in the context only 1 hashmap i have as a class variable....being private static HashMap mapOfTaskTypesWithTaskDetailLists = new HashMap();

Could this be the cause of the problem? That for some reason the variable isnt unique per logged-in user but is somehow shared between the sessions on the server?

I'm curious to your ideas.....

Much thanks and regards,

Hugo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hugo,

Static class variable is exactly the cause -- it is shared between all instances of the class, so there is no "per logged-in user" divide.

If you remove "static" modifier then you get unique variable per controller instance -- i.e. even if same user running several applications, every application will have own per-user set of tasks/queues.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Valery,

or i could just put it in the context right?

much thanks,

Hugo

Former Member
0 Kudos

Hugo,

Yes, this would be the same: context node with cardinality 0..n and 2 attributes (one for task, second for queue) is essentially same as your Map.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Valery,

That is also an option i guess but what i did now is make a context attribute of the type HashMap under the root contextnode. Is about the same right?

regards,

Hugo

Former Member
0 Kudos

Hugo,

If you talk about "sharing" this variable -- then yes, there would be separate instance per-controller.

VS

Former Member
0 Kudos

Looks like it works now. Thanks alot to confirm my suspicion....

regards,

Hugo

Answers (0)