1

A client wants a web application that performs a calculation based on text inputs, pulldown selections, checkbox selections, etc. They want to persist form data input but they are don't want to store them on the server. Instead they prefer to retain the inputs locally.

I've been searching and determined that this not a standard approach. Then I came across HTML5 Storage but it looks like that option isn't exactly what I thought it was.

Client wants to be able to save and load sets of inputs such as mortgage scenario 1 or mortgage scenario 20 year. Basically like a "save as" and an "open" button.

I reported back that this approach isn't really feasible and a server database or some other form of server persistence is the norm.

Am I way off base in being insistent that we need to use a database? Or are there any options I'm not aware of such as jquery?

jeff
  • 3,618
  • 9
  • 48
  • 101
  • Well if the client wants local storage, they must have their reasoning for that I assume – so what is it? As long as they are aware of the limitations (strictly tied to one specific client browser on one machine), I don’t see what the problem is. – CBroe Feb 27 '14 at 21:18
  • @CBroe I'll ask the project manager again, but I think they don't want to have to maintain a database. The problem is I don't know how to implement in a web application "file open, browse to hashmap of values file, load the file and have all the html form widgets update accordingly" Can you guide me towards the right api? – jeff Feb 27 '14 at 21:28
  • First you were talking about HTML5 local storage, now about text files – those are two completely different things. Anyway, to get access to (text) files on the client you will have to use an `input type=file`, and from there on you can go with the HTML5 File API. (And for “saving” modified data back to the client, that’ll involve a normal download dialog.) – CBroe Feb 27 '14 at 21:31
  • @CBroe I mentioned HTML5 but stated that I don't think it will do exactly what I want, which is to store the all the HTML input states to a text file, using a save as. So later one can do open file and the form state is restored. I know HTML5 can store the state but only 1 state at a time. Client wants it to be like MS word where you can save a bunch of files containing form state (The app is a mortgage calculator and perhaps a user may want to reload a different loan configuration) Is this possible? – jeff Feb 27 '14 at 21:49
  • _“I know HTML5 can store the state but only 1 state at a time.”_ – whatever you mean by that, it’s not true. “HTML5” on itself doesn’t store anything – if we are talking about _HTML5 Local Storage_ here, that can store as many value as you want. As for the “open file/save file” approach – I already gave you the keywords on how to do that in my previous comment. – CBroe Feb 27 '14 at 21:54
  • Yes, I mean HTML5 local storage. And by 1 state I mean the form as a whole, which, yes has many values. – jeff Feb 27 '14 at 22:07
  • Could be several _different_ forms (/different instances of the same form), no problem … – CBroe Feb 27 '14 at 22:59
  • Your client is a moron. Snap them back to reality by politely explaining the difference between a desktop and a web application. If that's not an option, look for an html5 localstorage framework that provides abstractions suitable to your needs. These may prove interesting: http://stackoverflow.com/questions/4461884/local-storage-html5-demo-with-code , http://diveintohtml5.info/storage.html – Ярослав Рахматуллин Feb 27 '14 at 23:29

1 Answers1

0

How about object serialization? If you use PHP as backend, you could gather form data to array, serialize it and output to downloadable file.

Another attempt is to catch form data into JSON using only JS, and then making user save it. Look here for more info: How to generate and prompt to save a file from content in the client browser?

Community
  • 1
  • 1
ex3v
  • 3,518
  • 4
  • 33
  • 55
  • 1
    Thanks. I'm using Java Server Faces. I'll have to check your answer out in more detail tomorrow. It's 5 O'Clock! – jeff Feb 27 '14 at 22:11