Change Report Design Before Running Report

Options
rmurphy
edited July 28, 2021 in Analytics #1
This example shows how you can use the BIRT Design Engine API and dynamically modify a report prior to exectution. This is useful when you have several reports that have been built generically, but need to be personalized based on the user or other identifiable information. This could also be accomplished with scripting within the report design itself, but this approach is useful when you have several reports and don't want to build the scripting logic into each report.<br />
<br />
This example contains a singleton class which returns instances of the Design Engine and a servlet filter which is responsible for changing the design. The servlet filter included with this example only changes the author name, however you could change any aspect of the design you wish. Common changes to the design include changing the data source or properties of the data source, changing images, changing CSS/Theme/Style settings, etc.<br />
<br />
In order for the servlet filter to be called, you must include a filter mapping in the web.xml. The Actuate BIRT Viewer supports both the open source sample viewer URL's and the Actuate Viewer URL's. To filter on the open source based URL's, the servlet-name you should use in the filter mapping is ViewerAdapterServlet. To filter on the Actuate URL's, the servlet you should filter on is IVServlet.
&lt; filter &gt;
	 &lt; filter-name &gt;DesignFilter&lt; /filter-name &gt;
	 &lt; filter-class&gt;com.actuate.sample.DesignFilter&lt; /filter-class &gt;
&lt; /filter &gt;
&lt; filter-mapping &gt;
	 &lt; filter-name &gt;DesignFilter&lt; /filter-name &gt;
	 &lt; servlet-name &gt;ViewerAdapterServlet&lt; /servlet-name&gt;
&lt; /filter-mapping &gt;
<br />
Modify the DesignFilter as needed, package the classes in a JAR and place in the WEB-INF/lib directory and restart the application.