Search code examples
grailsgrails-2.0grails-controller

Grails render a loading page while retrieving data


I have a web application that takes a while to load up the initial page. The main screen has a lot of data with multiple datasources, thus the load time is longer than I would like.

I would like to have a splash screen rendered immediately, while the controller continues to get the data for the page.

My controller pseudo code would look like this ( I know having the render twice will not work but this is what I would like to have happen) :

  def index() {
          render view: 'MyTempView'
          methods to go get data
          render view: 'expectedView' model: [all my data]
  }

Does anyone have any suggestions?


Solution

  • You can show the splash screen and get the data with ajax. When the ajax call is back with data/html you just hide the splash div and show the data.