Caching object in session - but what if you have up to 5 levels to edit?

Caching object in session - but what if you have up to 5 levels to edit?

Old forum URL: forums.lhotka.net/forums/t/743.aspx


JCardina posted on Thursday, July 27, 2006

I'm porting a winform csla app to asp.net and I've come across an issue I'd appreciate any advice on.

In the winform app we have edit forms for objects, let's say the object is an invoice.  In that invoice form we have a client, that client is a drop list with a button that can open a client entry form to create a new client in a popup form so that the user doesn't have to leave the stuff they are editing on the invoice to create a client nor to have to create a client before creating a new invoice. 

On that client entry form is a client group selection which has a button which opens a client group for editing or creating a new one etc etc.

In the winform app this scenario can go as many as 5 levels deep (i.e. 5 modal popup forms potentially) from the first main object being edited.

I want to replicate that behaviour in the asp.net app, but if I cache the initial Invoice object in session under "currentObject", the user edits some fields in invoice then decides to make a new client for that invoice so they click on client and another page pops up to enter the client, in theory I put the client in the currentObject slot in session, overwriting my Invoice object that was half edited previously.

In the original CSLA 1.x each type of object was cached separately in session, I can see the value in switching to a single session object, but this is an isssue in my case. I've considered that I know I only need to go at maximum 5 levels deep so I could have 5 currentObject slots, but then I need a whole system to manage what is in where and it starts to get out of hand.  Going back to a separate session variable per object seems like a bad idea.

Wondering how others handle this sort of thing or if I'm not thinking about it correctly / going about it the wrong way.

 

ajj3085 replied on Thursday, July 27, 2006

I think you're approaching it the wrong way.  You won't be able to mimic your forms UI very well on the web; yoru Winforms is stateful, and the web is not.  I don't think that the n-level undo is going to be useful at all in the web world.

JCardina replied on Thursday, July 27, 2006

I don't think I explained the situation very well, this has nothing to do with n-level undo, I've never used that functionality even in the winform app.  Think of it like editing one object then needing to add and edit another object while in the midst of editing the first object so that you can select it on the first object.

Or put another way, if I have only one "currentObject" in session I have a problem when the user is editing two different objects "simultaneously".  If I go back to the original CSLA 1 method of using a different session variable for each type of object it would solve the problem, but I'm trying to see if there is another way to better accomplish this before I resort to that.

ajj3085 replied on Thursday, July 27, 2006

Opps, my mistake.  I thought you were concerned about n-level undo.

You could keep seperate keys in the Session object, storing each object on the way, so you have a page that only looks at one particular key, say 'My5thChildObject.'

vicky_iit replied on Thursday, July 27, 2006

hi

I wrap my session objects conceptually in "context" classes. This way i can group similar objects which fall under one logical group and dispose them together. For eg. all customer related info would be in a CustomerContext class, an object of which would hold customer related variables in session. this is a simple and easy to manage technique which i find very useful.

in yr case yr Context class can have a hold a reference to other context class.

thanks

Viv

JCardina replied on Thursday, July 27, 2006

vicky_iit:
I wrap my session objects conceptually in "context" classes. This way i can group similar objects which fall under one logical group and dispose them together.

 

Hmmm..yes, interesting that gives me some ideas, thank you!

Copyright (c) Marimer LLC