简体   繁体   中英

Grails application controller groovy issue

I'm building a grails application and loading my backend by converting my csv tables into json files and rendering them to index.gsp for reading.

Most of the functionality of the dashboard is done, but there is a major flaw in my code as in, i'm loading JSON files of size 55 mb onto the browser everytime a selection is made. This is absolutely not recommended and there should be a middletier(or socket etc) or something, which takes the main json file and gives the browser exactly what is needed to show the data visualization, the size of which should be in kB for best performance

I am very new to this and was trying to resolve this via the javascript part of my code, but the problem lies with my groovy controller part and I must have a placeholder to store the json file and pull only relevant data on my browser to prevent a crash.

Any suggestions/approaches to this problem?

UPDATE :

So, after consultation with a javascript guy, I will have to use AJAX calls in both index.gsp and controller groovy part such that I pick only the relevant data in the browser and the remaining data lies in the controller such that every time a filer is changed, only the relevant data comes to the browser

I'm a beginner in AJAX, groovy and grails. After searching for a while, it seems I can use AJAX driven selects in GSP and also the remotefunction() Also, using filters plugin or some kind of "params" have to be used to solve this issue

Any suggestions/approached will be appreciated as to how to proceed in the same

If by loading the backend, you mean that you are creating objects in your database or memory, you can do this very easily through the BootStrap.groovy in the conf folder.

Look at the "Creating Test Data" part of this page for more information:

https://grails.org/Quick+Start

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM