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)
Redired to another report is session variable not found
canutri
Is it possible to redirect to another URL in the reports initialize event? I need to have some session variables available - via a .jsp that mimics a user login - to control some report queries for filtering purposes. If the session variables are not found I'd like to redirect to the setup.jsp. I've got the session variable tests working, but am not sure how to go about the redirect.
Thanks,
Daron
Find more posts tagged with
Comments
mwilliams
Hi Daron,<br />
<br />
I know you can put something like this in a text box in a report to redirect your report. If your session variables are not found, you'd set the global variable to false where you find out and this script will cause a redirect.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<script type="text/javascript">
function forward() {
if( <VALUE-OF>reportContext.getGlobalVariable("forw");</VALUE-OF>){
var temp = new String(location.href);
location.replace("http://www.google.com");
return false;
}
}
forward();
</script>
</pre>
<br />
You can drop any tables and such in your report design in your beforeFactory script so that the dataSets are not executed.
canutri
Michael,
That works nicely; although, I'd prefer to have code in the Initialize event to avoid having the phantom (hidden) text element. If I can use javascript & java in the Initialize event, why does location.replace not work by itself? Just being curious and eager to expand my BIRT scripting knowledge.
Would you please elaborate on dropping the tables in the beforeFactory. I get the concept, but am an sure how to "drop" the tables. Is this done from a method in reportContext?
Daron
btw - thanks for such a quick response
mwilliams
To drop a table, name the table in the property editor, then in the beforeFactory, put:
reportContext.getDesignHandle().findElement("myTable").drop();
That should do it.
canutri
<p>Hi Michael,</p><p> </p><p>I'm revisiting this post as I now would like to prevent my parameters dialog from appearing when the session variables are missing. I've tried using the drop() method as described above for tables, but this has no effect on parameters.</p><p> </p><p>Would there be another way to prevent parameters from appearing? I don't think the getDefaultValueList, getSelectionValueList or validate events are suitable.</p><p> </p><p>Daron</p>
mwilliams
<p>I don't know that you'll be able to do anything before the parameters, so you'll likely have to check the session variables before calling the report.</p>