Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Objects

 
Mrigasira Srinivas
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I am placing an object containing data retrieved in session for displaying it on multiple screens. When the user clicks on the save button, I need to update the session object (such that I can display the changed data if there is an error for the user), and also have the old object in order to make some comparisons. I have tried placing the same object in session with two different names, but that did not help. Can someone please let me know what I am doing wrong?
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you need to keep both of the objects in your session-set 2 different attributes with 2 different names.
if you have problems with your code - post it here.
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you are adding 2 entries into your session which actually both reference the SAME java object, i.e. the changes made to the object will be displayed regardless of which key you use to retreive it from the session.
You will need to create a COPY of the original object, apply the changes to the copy and then add this copy into the session.
 
Mrigasira Srinivas
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andy... That is what I was doing - putting the same object in session with different names. Copy seems to work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic