Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Hidden tables executing queries
Tubal
Hi there.
I've got a report that is set up with two grids. The first grid holds the actual report, the second holds a label saying "not authorized to view report". If the user is authorized, they see the report grid. If they are not, they see the other.
I use an md5 hash in a cookie and compare it to an md5 hash I create in the beforeFactory event, and also build report parameters based on a user id passed with the report URL.
The problem is, even when the first grid is hidden, it's still executing the queries that build the tables within this hidden grid. So the report might take 30+ seconds to run, and then when the report is finished, they see the "not authorized" grid.
I'm wondering if the "pre-report" stuff is fooling the report into thinking it needs to run these queries even though they are not visible?
Thanks for any help.
Find more posts tagged with
Comments
CBR
Hi Tupal,<br />
<br />
BIRT generates a report using two phases: Generation and Presentation. The generation phase executes all dataset queries prepares the data and builds all the internal stuff needed to render the table.<br />
Presentation phase is done right after generation and renders the element into the specific output (like PDF, HTML,...)<br />
<br />
Visibility is just limited to the presentation phase which means:<br />
The grid is always generated regardless of the users privileges (all the data is fetched, all calculations are done,...). If the heavy lifting is done it just skips presenting the element if visibility is set to false.<br />
In addition you might introduce a security issue if you allow the user to export data as csv, because even non visible elements can be exported as a csv file, which means that it might be possible that a user can download the data even if he doesn't have the privilege to see the grid.<br />
<br />
The best way to implement what you want is to remove the first grid before generation happens. This will ensure that there is no logic (sql,...) executed that is part of the first grid:<br />
<br />
1) Set property name of first grid. I m assuming that you set name to firstGrid for this element<br />
2) add following lines of code to beforeFactory event of the report:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var firstGrid = reportContext.getDesignHandle().findElement("firstGrid");
firstGrid.drop(); //this line removes the grid from the report object model just for this run
</pre>
Tubal
That did it.
Thanks for the help, and the great explanation.
Phil
rsenden
<p>I think I may have a much more elegant solution for this issue, which doesn't involve dynamically removing report elements.</p><p> </p><p>I have created a scripted data set named Repeat, with single column REPEAT_NUMBER and parameter NumberOfRows. As the name suggests, this data set simply returns NumberOfRows rows.</p><p> </p><p>Now, if I want to have an optional item, I simply wrap it within a list named OptionalItemList. The actual content is added to the OptionalItemList details, and OptionalItemList is bound to the Repeat data set, with the NumberOfRows parameter set to either 0 or 1 based on some expression. Whenever the expression returns 0, none of the list details will be evaluated nor displayed.</p><p> </p><p>The attached report design shows a simple example of this approach (please note that this example was created using BIRT 2.6.2).</p><p> </p><p> </p>