Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Refresh report using HTML button
buel2
<p>Hi all,</p>
<p> </p>
<p>I have a report with no parameters. Now I want to refresh that report <u>without having to close and open it again</u> so that, for instance, it's shows the current time. So I put a HTML button on the report and now need to add some code to the OnClick event of that button. What code do I put there?</p>
<p> </p>
<p>Thanks in advance,</p>
<p>buel2.</p>
Find more posts tagged with
Comments
kclark
<p>I think it should be something like this:</p>
<pre class="_prettyXprint _lang-">
function refreshReport() {
window.reload();
}
</pre>
drbud
<p>Thanks for your replay. It's been a while and I've tried several options found on the internet but still no luck
</p>
<p> </p>
<p>This is what I have. A report with:</p>
<p>a HTML text item containing: <strong><VALUE-OF format="HH:mm:ss">new Date()</VALUE-OF></strong></p>
<p>a Data item containing: <strong>Formatter.format(new Date(),"hh:mm:ss")</strong></p>
<p>a HTML button containing the script: <strong>this.onclick = function(event) { window.location.reload(true); }</strong></p>
<p> </p>
<p>When I run the report the current time is shown. So far so good.</p>
<p>Now when I click the refresh button the window is refreshed but the time stays the same.</p>
<p>So what am I doing wrong? Just can't figure it out...</p>
pricher
<p>Hi,</p>
<p> </p>
<p>window.reload() does not re-run the report: it simply reloads the window. Because you get your date at report generation with a new Date() statement, it will always show the original date.</p>
<p> </p>
<p>Since you are using an HTML button in your report, I am assuming you are using the commercial version of BIRT. In that case, you can use the following script on your button:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">this.getViewer().submit();</span></p>
<p> </p>
<p>This will submit a JSAPI call to re-run the report.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
drbud
<p>Hi pricher,</p>
<p> </p>
<p>Thank you for your explanation and possible solution.</p>
<p> </p>
<p>I've changed the script to <strong>this.onclick = function(event) { this.getViewer().submit(); }</strong></p>
<p>Now when I run the report en click the button this error message pops up: <strong><span>java.lang.NullPointerException</span></strong></p>
<p>What is causing this error?</p>
<p> </p>
<p>BTW I'm creating this report in Actuate BIRT Designer Professional</p>
pricher
<p>Which version of BIRT Designer are you using? Are you running the report in a Web Viewer? If you can, please send us your report design.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>P.</p>
drbud
<div>Hi,</div>
<div> </div>
<div>* The "About Actuate BIRT Designer Professional" says I'm using:<br>
Actuate BIRT Designer Professional<br>
Version: 11.0.4<br>
Build id: 20121023<br><br>
* Yes, I'm running the report in Web Viewer<br>
</div>
<div>* See attachemt for my report design</div>
<div>[sharedmedia=core:attachments:10723]</div>
<p> </p>
pricher
<p>Hi,</p>
<p> </p>
<p>I am unable to download your rptdesign. Can you upload again? Thank!</p>
<p> </p>
<p>P.</p>
drbud
<p>Hope this one works...</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Yep, my example did not work in 11SP4.... It appears the functionality of the submit() function behaves differently.</p>
<p> </p>
<p>After many tries, I came up with a solution that works well in 11SP4. On the text item (now with a yellow background), I added a bookmark named "text". On the button event, I changed the code to this:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">this.onclick = function(event) {<br>
var vid = this.getViewer().getCurrentPageContent().getViewerId();<br>
var t = document.getElementById(vid + "_text");<br>
t.innerHTML = new Date().toLocaleTimeString();<br>
}</span></p>
<p> </p>
<p>The part about getting the viewerid (vid) is important. When Actuate renders the report in HTML, it prefixes any bookmarks with a unique viewerId to ensure that there would not be any confusion if load the same report twice on the same page.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
drbud
<p>Hello pricher,</p>
<p> </p>
<p>Thanks a lot for all the effort you put in solving my issue. Your solution works! However, I don't really (really don't) understand how things work. Also I am wondering now what to do when I need to refresh more than 1 text or data item and / or one or more datasets...</p>
<p> </p>
<p>The reason I got to this issue:</p>
<p>When I have a report that has a parameter, refreshing it is quite simple. But when there is no parameter this does not work. See attached screenshots. So I could add a dummy parameter to my report but I think that's an awful solution...</p>
pricher
<p>If you need to refresh a report with new data, then the best way is to re-run the report from the click of a button. To do this, you can use the following code on your Refresh button:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">this.onclick = function(event) {<br>
window.open('./executereport.do?__executableName=/Report Designs/RefreshReport.rptdesign', '_self');<br>
}</span></p>
<p> </p>
<p>executereport.do is the command to execute a report from a URL. The above syntax will run it from your actual iportal context.</p>
<p> </p>
<p>__executableName points to the rptdesign on your iServer volume. Change accordingly.</p>
<p> </p>
<p><strong>Nota bene: </strong>The report needs to be executed from iServer. If you run it from BD Pro, the rptdesign will not be found.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>