mrmangosir Posted September 17, 2012 Share Posted September 17, 2012 Hi,Thought I'd share how to create an auto share on Jasper CE 4.7. This may work on lower version, if they have the "refresh" functionality. One word of warning, this does not solve allowing only certain reports to refresh and not others, but its not too difficult.So go to <jasperInstall>/webapps/jasperserver/web-inf/jsp/modules/viewreport/viewport.jsp.Open the file and go to around line 80/81 and after <div id="viewerToolbar" class="toolbar"> add the below attached code. So your next task will be to have it adjustable. That is up to you how you want to be able to change that value.Be warned that once that JSP has been saved and Tomcat restarted, *all* reports will not autorefresh.Have fun.Code:<script type="text/javascript"> setInterval(function(){ document.getElementById('dataRefreshButton').click(); }, 10000); // every 5 seconds</script> Link to comment Share on other sites More sharing options...
mrmangosir Posted September 28, 2012 Author Share Posted September 28, 2012 If anybody wants the full source to this, please post here and I will drop it in. After seeing all the questions about auto refresh in CE for years, might be worth the while to someone :) Link to comment Share on other sites More sharing options...
Solution lucianomarqueto Posted July 26, 2013 Solution Share Posted July 26, 2013 Hello,I used your idea and added the option to turn on and off, so you can turn the auto refresh only the reports you want. This example was done on version 5.1. To add the button auto refresh change the following files: in file jasperserverscriptsreport.view.runtime.js change the line 41 of$(Report.DATA_REFRESH_BUTTON).observe( 'mouseup', function() { to $(Report.DATA_REFRESH_BUTTON).observe( 'click', function() { in file jasperserverWEB-INFjspmodulesviewReportViewReport.jspon line 63 after the imports scripts add the following script <script > var auto function iniciar() { auto = self.setInterval( function(){clicar()}, 300000);//5 minutos document.getElementById( 'iniciar').style.display = "none"; document.getElementById( 'parar').style.display = ""; } function parar() { auto = window.clearInterval(auto); document.getElementById( 'iniciar').style.display = "" ; document.getElementById( 'parar').style.display = "none"; } function clicar() { document.getElementById( 'dataRefreshButton').click(); } </script> And in line 158 (before pasting the script) change the code <c:if test= "${param.decorate != "no"}"> <ul class="list buttonSet"> <li class= "leaf"><button id="back" class= "button capsule text up" ><span class="wrap" ><spring:message code= "button.back"/><span class="icon" ></span></ span></button ></li> </ul ></c:if> To (just added the two buttons) <c:if test= "${param.decorate != "no"}"> <ul class="list buttonSet"> <li class= "leaf"><button id="back" class= "button capsule text up" ><span class="wrap" ><spring:message code= "button.back"/><span class="icon" ></span></ span></button ></li> <li class= "leaf"><button id="iniciar" class= "button capsule text up" onclick="iniciar();" title ="Iniciar a atualização automatica a cada 5 min"/><span class="wrap" >Auto </span></ button></li > <li class= "leaf"><button id="parar" class= "button capsule text up" style="display :none" onclick="parar();" title= "Parar atualização automatica"/>< span class ="wrap"> Stop</ span></button ></li> </ul ></c:if> Be happy :D Link to comment Share on other sites More sharing options...
mrmangosir Posted April 30, 2014 Author Share Posted April 30, 2014 Thanks for the response. I will test this within our system. Apologies for the late response :( Link to comment Share on other sites More sharing options...
jordan.lamarche Posted August 26, 2014 Share Posted August 26, 2014 You guys just made my day. Thank you for sharing these useful modifications.Best regards,JL. Link to comment Share on other sites More sharing options...
lucianomarqueto Posted July 16, 2015 Share Posted July 16, 2015 In new versions edit the file ~/jasperserver/optimized-scripts/report.viewer.page.js instead of JasperServer file jasperserverscriptsreport.view.runtime.js For this look inside the file by Report.DATA_REFRESH_BUTTON to locate what should be changed as mentioned in answer (mouseup -> click) Link to comment Share on other sites More sharing options...
pokornyjan Posted March 14, 2018 Share Posted March 14, 2018 Did you try It with version 6.3?I added button but refresh refresh does not work.Thank you for helpJan Link to comment Share on other sites More sharing options...
omer.etrog Posted April 9, 2018 Share Posted April 9, 2018 the problem is that that the code is using 'mouseup' event and not 'click'.instead of the above code, you can use:<script> function triggerEvent(el, type){ if ('createEvent' in document) { // modern browsers, IE9+ var e = document.createEvent('HTMLEvents'); e.initEvent(type, false, true); el.dispatchEvent(e); } else { // IE 8 var e = document.createEventObject(); e.eventType = type; el.fireEvent('on'+e.eventType, e); } } self.setInterval(function(){ var el = document.getElementById("dataRefreshButton"); triggerEvent(el,'mouseup'); },10000); </script>[/code] Link to comment Share on other sites More sharing options...
pokornyjan Posted June 25, 2018 Share Posted June 25, 2018 Hi omer.etrog,your code is working. (works permanently and over all reports).How do I set the code for only one report?Thank you for helpJan Link to comment Share on other sites More sharing options...
pokornyjan Posted July 12, 2018 Share Posted July 12, 2018 I found the solution, Thanks all Link to comment Share on other sites More sharing options...
kanushtika08 Posted August 9, 2018 Share Posted August 9, 2018 hi how do i set the code for only one report? Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now