cancel
Showing results for 
Search instead for 
Did you mean: 

How to serialize/deserialize a Context to/from a file?

Former Member
0 Kudos
239

Hello,

I have a DynPro application which contains an evaluation form for employees. Once pressing "Submit" the whole form is being written to an SQL table.

The evaluation form is very long and it could be that one will want to save the evaluation so far (without submitting it to the DB yet) and continue on another day.

In order to do that, I need to save the temporary context, perhaps serialize it to a file.

My idea was the following:

1. In case a user selects to temporary save the evaluation, I should serialize the whole context to a file, with the employee ID as the filename.

2. When a user selects to evaluate a certain employee, I will go over the folder which contains the temporary files and check if a file for this employee ID exists.

3. In case it exists, I will replace the current instance of the Context with the context which has been saved on a file.

I have two question:

A. Is it possible to serialize the whole context to a file?

B. Is it possible to retreive this context and replace the default instance which Dynpro creates with the serialized contex?

I am already familiar with this post:

In this post Valery explained how to transform the Context to an xml file using SAX Parser, but I don't need that, all I need is wrting the whole context as a bulk to a file and then retreive it. And even if I'll use this method, is it possible to replace the default context with the saved one without going over the Context and setting it node by node?

Roy

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Concerning the serialization: Can't you just extend the database with tables for temporary results and use that? Or even better: Add a flag to each table indicating whether a result is final/temporary. That way your mechanisms for storing temporary and final results are identical and make the application easier to maintain in the future.

Message was edited by: Pascal Willemsen

Former Member
0 Kudos

Hey Pascal,

I've already thought of that...

The problem is that the Context is very complicated one, writing it to the DB took a lot of effort, so if I'll use this method I will have to go over node by node and assign the value again. What I want to do is to save that by saving let's say an "image" of the context which can be uploaded as a whole at one call. But the more I think of it I come to the conclusion that it might not be possible...

Roy

Former Member
0 Kudos

hi Roy,

Well i haven't read that Weblog of VS but if you want to use an XML file for persising all your context values. you can do it using castor APIs in a java class and then using that class in your dynpro. This way all your values will be stored in XML file and then u can retrieve and modify them.

If u wanna go this way, ask me to explain it further

Rgds,

Vilish

Former Member
0 Kudos

Hey Vilish,

If it will be easy to upload the Context from xml file than why not... But please read Valery's post first, see if you have something different or new you had in mind.

Roy