views:

27

answers:

4

I am building a form in Net framework 4.0 using linq to sql , and had a question about object persistence.

I have a case where a user is asked to fill out a very long form several pages in length. Since it is so long, there is a need to SAVE the data midstream.

Session level persistence is not an option, since they could SAVE the form midstream, turn off their browser, and retrieve the form partially filled later.

The form fields are mapped to a DB table, with each form being a DB row, however, several fields are required, and are set in the DB as NOT nullable. I want to provide the ability to save the data values incompletely.

What would be the best approach for saving the object midstream in it's incomplete state, then, later when the user SUBMITS the form, submitting the validated and complete object.

NHibernate is also not an option.

Any good ideas appreciated.

A: 

I would recommend something like Workflow Foundation, if I didn't have such a bad experience with it last time around.

leppie
A: 

Since you want people to be able to continue filling in the form where they left off, even if they leave the site or restart their browser, saving the partially completed form in the ViewState or Session objects is out.

I think the two ideas that would be the simplest to implement would be to either store all the partially completed values in browser cookies. Or even better (if you have any control of the database) to create a new table in the db with nearly identical fields to the form table. Save the values entered in the partially completed form in that table (call it Form_Incomplete or something), then only insert into your form table once the user does the final save upon completion of the final page.

eoldre
A: 
  • You could shove it in a cookie (or the forms auth ticket data) if you want them to be responsible
  • You can use asp.net cache if you don't mind the server overhead.
StingyJack
A: 

It seems to me that you need to answer several questions.

  1. How long does this data live.
  2. How do users "resume"
  3. Where do you want to store it
  4. What format do you want the partial data in.
  5. How do you plan on dealing with versioning issues.

I would definitely consider serializing the data on Session End and storing it in a database. When the users return you can look for it and ask if them if they want to resume or not. This takes care of all of the above except for #5. Whenever you change the object model it does however create a potential for compatibility issues with your serialized data.

Another option I might go with is ask all the required data early and then you can save whenever you want.

Another option is to simply relax the NOT nullable rules and then again you can save whenever you want.

Conrad Frix
Conrad : there is a SAVE button on the form as well as a SUBMIT button. The SAVE would save incomplete, the SUBMIT would post the finished form to the DB. Users would resume however they wish. Versioning would not be a problem, SAVED information can be retrieved from the most recent SAVE, and anything can be overwritten. Only the SUBMITTED data is relevant.I don't know how an application might "relax" nullability on a database table, but that is not an option for me.
Ash Machine