0

I am developing jira and using variables in velocity, which are exposed as public getters in java plugin code. Everything seems good, I am getting my java code results in output.vm inside velocity template after processing excel file but I would like to add progressbar which is coded in pure javascript, so I have some js files and I would like to get velocity variables like current number of processed issue, and how many issues are there to calculate progress. I can't bring solution because when I am attaching <script> inside velocity .vm and alerting after timeouted function the variable issueNumber is not changing at all, its 0. issueNumber is public instance variable in java.

    <script>
    function test() {
        var get = $issueNumber;
        alert(get);
    }
    setTimeout(test, 5000);
    test();
    </script>

My public variable issueNumber can be rendered in velocity as result after iterating in output velocity file, but can't be used as indicator in javascript where current progress is. Basically I need runtime variable not render time variable.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
jira jira
  • 17
  • 6

1 Answers1

0

The velocity engine just replaces $issueNumber with the constant value during html page rendering and it happens only once so it is impossible to track any changes in that way. To achieve what you want you can implement an endpoint on the server-side which returns the actual state of the progress and do ajax calls to it in your script with some interval.

Egor Lyashenko
  • 738
  • 1
  • 8
  • 23