Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Download from temporary table approach

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a spring boot app. So on the User Interface, there is an Advanced Search section where user selects 5-7 things from the text box and based on these parameters, a web service is called. The webservice returns the search results in a JSON format and those records are displayed in a tabular format in the User Interface. My goal is to download all the records into an excel file when a user hits a Download button.

So I have a Download button below the tabular section where all records are displayed.

If I have to download the records in excel format as soon as user clicks the download button, is there something like the following feasible or a good solution?

As soon as search results are sent back to the user interface in JSON format, I can have those records inserted into some temp table in the database. So when a user clicks on the Download button, using Java, I can grab all the records, convert it into CSV file and present it to the user for saving purpose. Please suggest if this is even possible or any other better approach .
 
Saloon Keeper
Posts: 12251
259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to store it in the database? Your client already has the data, as you are displaying it in your user interface.

I suggest that instead of your current approach, you offer the data directly to the client as a CSV file (instead of as JSON) and then you display the CSV in your user interface. Then when the user hits "Download" (or rather "Save", since you've already downloaded it), you can just save the CSV you're already displaying.
 
Jack Tauson
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Why would you want to store it in the database? Your client already has the data, as you are displaying it in your user interface.

I suggest that instead of your current approach, you offer the data directly to the client as a CSV file (instead of as JSON) and then you display the CSV in your user interface. Then when the user hits "Download" (or rather "Save", since you've already downloaded it), you can just save the CSV you're already displaying.



Hmm. I am using this (http://jsfiddle.net/jqwidgets/6HRU8) widget to display all data in tabular format and they are asking to supply a URL hosted on the server and that's causing issues to me in setting up virtualhost on Apache etc. The reason they are asking is because the records are around 2000 or more and to handle the load I need to have their solution on my server.

I will try to find some other  UI thing to display records and then look for download options
 
Stephan van Hulst
Saloon Keeper
Posts: 12251
259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If processing the records on the server side is heavy work, then you may want to cache them just before you convert them to a response message.

Then you have one end-point that converts a page of cached records to a JSON result, and you have another end-point that converts all cached records to a CSV file.
    Bookmark Topic Watch Topic
  • New Topic