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)
How to change dataset of report parameter at runtime
steeltrain
Hi,<br />
<br />
I am trying to change the dataset mapped to my report parameter at runtime, by placing this bit of code inside the initialize() method of my report design:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var paramsList = reportContext.getDesignHandle().getParametersAndParameterGroups();
... //Loop through params list and get the relevant parameter handle
parameterHandle.setProperty("dataSetName", "myDataSet");
</pre>
<br />
Although the code works, I realise that the initialize method is called only <strong class='bbc'>after</strong> the parameter screen is cleared (let alone displayed), i.e. after all the report parameters' statically-defined datasets have already been opened. My intent is to change the dataset <strong class='bbc'>before</strong> the parameter screen is displayed, so that the value list of my report parameter is taken from "myDataSet". Is this possible at all? I haven't been able to find any event handler that gets executed before the initialize() method, so I can do the dataset switching.<br />
<br />
Would be very much grateful for any advice rendered!
Find more posts tagged with
Comments
mwilliams
I don't know of a way to change the dataSet that a parameter is tied to because like you said, the parameters are called first. What is the reason for the switch? Can you explain a little more about the situation? Maybe I or someone else will be able to suggest something else you could do to achieve the same thing. Let me know.
steeltrain
Hi Michael,<br />
<br />
Thank you for responding to my post. The reason for the switch is because I'd like to use the same report for different database engines. Hence, I wanted to be able to populate param values with the appropriate database-specific query at runtime.<br />
<br />
I have tried a workaround, in which I do not try to change the dataSet of a report parameter, but instead change the dataSet's queryText, and the oda properties of the dataSet's dataSource. To be precise, in the dataSet's dataSource's beforeOpen method, I changed the dataSource's odaUrl, odaDriverClass & oda login properties accordingly at runtime, via its OdaDataSourceHandle. Then, in the dataSet's beforeOpen method, I changed the queryText to the appropriate database-specific query.<br />
<br />
However, I observed that although I had changed the dataSource's oda properties at runtime, the dataSet still seems to be using the statically-defined oda properties, for the parameter screen. Is this expected behaviour? If yes, I wonder if there is any other workaround that can help me achieve report reusability across different database engines?<br />
<br />
Thank you for your help<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="74497" data-time="1299686659" data-date="09 March 2011 - 09:04 AM"><p>
I don't know of a way to change the dataSet that a parameter is tied to because like you said, the parameters are called first. What is the reason for the switch? Can you explain a little more about the situation? Maybe I or someone else will be able to suggest something else you could do to achieve the same thing. Let me know.<br /></p></blockquote>
mwilliams
Unfortunately, that was going to be my suggestion to try. What is your BIRT version?
Maybe you could possibly create parameter for all your different options and use a custom JSP parameter page using the tag library for each different use of the report, so that you only show the parameters you want to see and call the report from there.
steeltrain
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="74500" data-time="1299688980" data-date="09 March 2011 - 09:43 AM"><p>
Unfortunately, that was going to be my suggestion to try. What is your BIRT version?<br />
<br />
Maybe you could possibly create parameter for all your different options and use a custom JSP parameter page using the tag library for each different use of the report, so that you only show the parameters you want to see and call the report from there.<br /></p></blockquote>
<br />
Hi,<br />
<br />
Thank you very much for your help and suggestions. I managed to get the dataset's properties to change at runtime after all, by setting my desired properties via "extendedProperties", rather than the oda handle.
mwilliams
Ah, great to hear! Let us know whenever you have BIRT related questions!
mwilliams
Can you by chance post in here how you used the extendedProperties to change the source?