Question

I have to process an Excel file in order to insert some data into a Mysql database on a web based application. I am using Spring MVC as the architecture.

The problem is I need to include a mid-step in which the user can review data to be inserted before actual insertion. So the typical process would be for the user to upload the file, then the application would show another webpage with the processed information, and a "Apply changes" button that would actually take all this information and store it into my database.

At first, in order to propagate the data in the file throughout the three steps (the first page where you upload, the mid-step page and the final controller action), I just used a form where I would use hidden fields to store the data, in order to avoid having to process the file twice (one for the result presentation in the mid-step, and the other for the actual data storing). The problem is the Excel file has so much information that my mid-step page gets overloaded and it takes too long to render (and to further process it in the controller when getting ahold of the parameters).

So I though about using either a temporary file or a temporary relation in my database to store the data between steps. Are there any other ways to propagate these data between controller actions? I wouldn't like to leave garbage data behind nor process the file again (since it takes quite some time) so what would be the best approach for this?

Était-ce utile?

La solution

I would go for a temporary table in this case, if the processing of it takes not too long. First you are able to use the sequences like in the final table and all you need to do is issue an "insert into select from" statement once the user clicks ok in the second screen. This would be a simple solution to implement i'd say and all the processing is done.

If the processing part is "huge" and the user could check certain things before this big task a solution could be to split up the processing in two parts and store this first results in a temporary file and implement a screen based on that one. After the user clicks ok you can launch an async task that does the heavy lifting and cleans the file after hes done.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top