how to keep objects from a xif in session?

how to keep objects from a xif in session?


for certain reasons(*) I am in need of a hashmap. This is pretty doable, but I can only story "Objects" into local variables or input/out-parameters of actions.
This prevents me of using webblocks.

I like to have the hashmap in a session-variable because it's only valid during that session.

How to handle this?

(*) I get a record-list of options with descriptions and prices from a webservice.
after i select an option i do a roundtrip to the webservice and I get the similar list back.
without descriptions and updated prices and some extra stuff.
So instead of having a double-for-loop because I really like to get the old record immediatly.
This is also the reason the database is out of the question, because I will have lots of updates by each select/unselect of an option.
Hi Statler & Waldorf

Directly you can't keep objects in session. An object is no more than a reference to a object in your extension and it only means something in that context.
You can always do a serialization and deserialization to base64 of the object inside your extension and store it as a text variable, but you need to keep in mind that session variables are stored in the ViewState and keeping a big viewstate is something that we usually don't want because it slows down our applications a lot.
However it was my workaround when  I needed to do that.

Hi Joost,

The main reason why you can't put Objects into session variables (apart from the performance issue) is because if for some reason a developer returned a Object that is not serializable (or with some children object that was not serializable) it would cause strange errors saving the session. These kinds of errors are also very hard to throubleshoot.

You can store it in session in the format of a RecordList, just not in a Object/Hashtable, even though it is not recommended to use recordlists in session for performance reasons.

@José: Session variables are not stored in viewstate.

João Rosado


I thought they were. My bad. So, where are session variables stored?

But now I got confused, how can we store a object as it was a RecordList? Can we cast a object to RecordList?

@joao thank for the answer, I will continue to fiddle with it.

@Jose thanks, I will look into the base64 thing (whatyaknow, Outsystems got builtin decode/encode from an Object)