Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:15:33+00:00 2026-06-05T22:15:33+00:00

I have a page X in my grails app which has a button to

  • 0

I have a page X in my grails app which has a button to display a chart. It will call a controller with a domain object’s id and the chart gets rendered in another page. Till here everything is clear to me.

However I have to reload the rendered chart page every 20 seconds. My website is a private one with few admin users only. So I decided to use simple javascript polling to do the refresh.
This is the snippet in the chart gsp page that I want to reload every 20 seconds. Maybe using javascript setInterval.
<g:render id="chart" template="/building/${chartTemplate}" model="${model}"></g:render>

My controller requires a sensor id to be passed in when creating the chart, can I use the java script to do that? If so, how can I get it to the javascript function from the controller which initially redirected it here.

This is my GSP template which renders the chart.

<div id="linechart"></div>
<gvisualization:lineCoreChart dynamicLoading="${true}" elementId="linechart" title="${title}" 
 width="${750}" height="${450}" columns="${columns}" data="${data}"/>

Some weird javascript I have used, but not working.

<input type="text" id="sensorid" disabled="disabled" value="${sid }"/>
            <g:javascript>
                var int=self.setInterval("chart()",1000);
                var sensid;
                function chart(){
                    var d=new Date();
                    var t=d.toLocaleTimeString();
                    sensid = document.getElementById("sensorid").value;
                }
                ${remoteFunction(controller:"building", action:"createChart", params:"'sid=' + sensid")}
            </g:javascript>

Is there a way in which the javascript can reload the page. Full page reload is also fine. I have near zero knowledge of javascript so any help is highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:15:35+00:00Added an answer on June 5, 2026 at 10:15 pm

    Since you mention reloading the entire page is acceptable, then two easy ways would be:

    1) Include a META REFRESH tag in your GSP. Eg:

    <meta http-equiv="refresh" content="5">
    

    This is quite convenient, especially if you don’t need to change the params (eg if the controller handles anything such as curent date/time used to update chart, etc).

    2) Either via Javascript “setTimeout” or a specific action, call a reload (or “history.go(0)”, or “window.location.href=window.location.href”).

    Eg for a button action to test it:

    <input type="button" value="Reload this page" onClick="window.location.reload();">
    

    or to do it automatically every 5 seconds, such as in this (extremely stripped down, so yes I’ve skipped things such as head, body and other tags..) HTML example:

    <script>
    setTimeout("window.location.reload()",5000);
    </script>
    
    Hello world.
    

    This gives you more control over exactly what you call, and could easily be modified to redirect to a different controller, same controller with new params, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Page Tab App, which has a landing page with a Log In
I have developed a grails/groovy application for a legacy database which has user maintenance
I have a very simple gsp page that has a button. I'm trying to
I have page where I use model which can have different types (depending by
I have page named page--news.tpl.php, which i created for my news page. But after
I have page (Default1.aspx) in which I am redirecting to another page (Default2.aspx) using
I have page which is redirected from htaccess. now I can pass the German
I have a Grails 2.0.0 project that was created using grails create-app . In
I am starting with Grails and want to have one page with multilanguage content.
I have installed jasper plugins for my grails application. Then in the list.groovy page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.