0

I am trying to use a progressbar for my grails application. I have a src/groovy/MyClass.groovy which does some function when called from a controller class called MyController. I need to show the progress of the work done by the MyClass.groovy on my MyWebpage.gsp when I click a submit button on the MyWebpage.gsp.

I referred to this but what I am not understanding is this part of the code:

<g:form>
<g:submitToRemote action="executeAction"  name="progressButton" value="start...."/>
</g:form>

What is executeAction and progressButton in this? There is not much information given on the documentation. Sorry for this basic question. Also, if anyone knows of a better approach to show the progress, please let me know. Thanks.

tim_yates
  • 167,322
  • 27
  • 342
  • 338
clever_bassi
  • 2,392
  • 2
  • 24
  • 43

1 Answers1

0

executeAction is the controller action which is called via ajax (see example action from the docs)

def executeAction = {

    for (int i = 1; i <= 100; i++) {

        //this updates the progress bar value for the progress id 123
        progressService.setProgressBarValue("123", i)

        //let's waste some time
        for (int a = 0; a < 10000; a++) {

            for (int b = 0; b < 1000; b++) {

            }
        }
    }

    render "the progress is done"
}

progressButton should be the name of the button, which is used later from the line <g:jprogressDialog progressId="123" trigger="progressButton"/> to probably update the status bar on the client.

But as you are asking about an alternative, i would suggest, to use just plain jquery(-ui) for this. Combining something like jquery-ui progressbar with jquery ajax calls should to the trick. Examples of this is given here.

Community
  • 1
  • 1
Mario David
  • 1,595
  • 11
  • 19
  • I am not making any AJAX calls. Honestly i have never worked with AJAX. Is there anything I could do to just show the progress bar after clicking submit and till the time another gsp is rendered? – clever_bassi Jul 22 '14 at 20:42
  • `` does exactly this - making a ajax call (perhaps without you knowing it (@see [docs](http://grails.org/doc/latest/ref/Tags/submitToRemote.html)). If you just want to a loading animation showing up until the http response from the form submit occurs, this could be achieved by listening to the form submit via js and then display a spinner: [example](http://stackoverflow.com/questions/8140946/how-to-show-a-loading-gif-mean-while-a-submit-form-is-being-executed-jquery) – Mario David Jul 22 '14 at 20:49