What I did was create a user parameter called NewParameter. I know, clever name, but this was just at test scenario. I have a table called counTable that will output the results of a dataset. Then, I used the following script in the tables onPrepare event handler (although this could be done in the reports Initialize event handler also):
tableContext = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("countTable");
tableContext.setPageBreakInterval(params["NewParameter"]);
That’s it. Now, when the report is displayed, a parameter will prompt the user to enter the number of rows to break each page on. This is useful when used with the Progressive Viewing feature to allow the user to really control pagination when embedding BIRT into an application. The completed report is below in XML.
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.14" id="1">
<property name="author">John Ward</property>
<property name="createdBy">Eclipse BIRT Designer Version 2.2.0.v20070620 Build <2.2.0.v20070626-1003></property>
<property name="units">in</property>
<text-property name="title">Page Break Interval</text-property>
<property name="comments">Copyright (c) 2007 <<Your Company Name here>></property>
<html-property name="description">A test report that will generate a data set with 6000 numbers, then assign the tables page break interval using a parameter.</html-property>
<text-property name="displayName">Blank Report</text-property>
<property name="iconFile">/templates/blank_report.gif</property>
<parameters>
<scalar-parameter name="NewParameter" id="6">
<property name="valueType">static</property>
<property name="dataType">string</property>
<text-property name="promptText">Page Break Interval</text-property>
<property name="controlType">text-box</property>
<property name="defaultValue">5</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<data-sources>
<script-data-source name="Data Source" id="23"/>
</data-sources>
<data-sets>
<script-data-set name="Data Set" id="24">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">count</property>
<property name="dataType">any</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">count</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">count</property>
<property name="dataType">any</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[x = 0;]]></method>
<method name="fetch"><![CDATA[if (x < 6000)
{
x++;
row["count"] = x;
for (y = 0; y < 6000; y++);
return true;
}
return false;]]></method>
</script-data-set>
</data-sets>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table name="countTable" id="27">
<property name="width">100%</property>
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">count</property>
<expression name="expression">dataSetRow["count"]</expression>
<property name="dataType">any</property>
</structure>
</list-property>
<method name="onPrepare"><![CDATA[tableContext = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("countTable");
tableContext.setPageBreakInterval(params["NewParameter"]);]]></method>
<column id="36"/>
<header>
<row id="28">
<cell id="29">
<label id="30">
<text-property name="text">count</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="31">
<cell id="32">
<data id="33">
<property name="resultSetColumn">count</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="34">
<cell id="35"/>
</row>
</footer>
</table>
</body>
</report>