Something I had a little trouble when making the dynamic report was how to specify the data source connections dynamically? In my case the solution is self-configure through having an environment variable which identifies the system as DEV, QAT, UAT, PROD. All the different projects could be built one time and deploy to different environment without any configuration change. I wanted the same for the reporting solution.
The ideas I read for making dynamic connections required to:
- Define the connection profiles pointing to the data sources
- Pass the connection profile name in the URL
var profName = "DEV-Localhost.conn"; try { profName = params["connProfileName"]; } catch (err) { /* continue... */ } reportContext.getAppContext().get("birt.viewer.resource.path") + "/report/config/" + profName;
Putting it all together...
- Create the dynamic web project to host the BIRT report engine runtime. In my setup I have "birt.viewer.resource.path" pointing to the WebContent folder. So I just need to point the report designers in <path>/report/design/ and the connection profiles in
<path>/report/config/
- Define a connection profile for the data source.
- Define a report parameter for the connection profile name.
- Duplicate the profile connection file and edit the URI address to the data source. Dev-Localhost.conn
- Go back to the data source and add
in the property binding section the connection profile store script from above.
- Test the report by passing as an argument the different connection profiles in the report generation URL.
http://localhost:8080/WR/frameset?connProfileName=DEV-Localhost.conn&__report=report/design/MyReport.rptdesign http://localhost:8080/WR/frameset?connProfileName=QAT-Server.conn&__report=report/design/MyReport.rptdesign http://localhost:8080/WR/frameset?connProfileName=ETC-Server.conn&__report=report/design/MyReport.rptdesign
No comments:
Post a Comment