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)
Customized pageNumber
Connae
I tried to customize the pageNumber in my pdf-report in a way that it starts with a given number on the first page instead of 1.
This works with the example-data of Birt with this code:
<method name="beforeFactory"><![CDATA[importPackage(Packages.java.lang);
reportContext.setPersistentGlobalVariable("pgstr", new Integer(params["page"].value));
]]></method>
and in a cell of the page-header:
<text id="31">
<method name="onRender"><![CDATA[newpagestr = parseInt(reportContext.getPersistentGlobalVariable("pgstr"))+pageNumber-1;
this.text = " Page Number: " + newpagestr;
]]></method>
<property name="contentType">auto</property>
</text>
But as soon as I try exactly the same in a report with my own data, I have the same number on every page.
Has somebody an idea about the reason?
Find more posts tagged with
Comments
JasonW
Are you using the viewer to test this? If so verify that in both cases you are using the /frameset mapping.
Jason
Connae
I tested it in my application. I tested it in my application. It seems the problem is in the way I fill in the data:
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[if(pferde!=null){
pferdIter = pferde.iterator();
}]]></method>
<method name="fetch"><![CDATA[if (!pferdIter.hasNext()) {
return false;
}
pferd = pferdIter.next();
// init default values
dataSetRow["halsbrand"] = null;
dataSetRow["hufNr"] = null;
dataSetRow["geschlecht"] = null;
dataSetRow["farbe"] = null;
dataSetRow["abstammung"] = null;
dataSetRow["verkaeufer"] = "";
dataSetRow["zuechter"] = "";
dataSetRow["hohe"] = null;
dataSetRow["halsbrand"] = pferd.getHalsbrand();
dataSetRow["hufNr"] = pferd.getHufNrRe() + "." + pferd.getHufNrLi() ;
dataSetRow["geschlecht"] = pferd.getBoGeschlecht()!=null?pferd.getBoGeschlecht().getGeschlecht():"";
dataSetRow["farbe"] = pferd.getBoFarbe()!=null?pferd.getBoFarbe().getFarbe():"";
dataSetRow["abstammung"] = pferd.getAbstammung();
if(pferd.getVerkaeufer()!= null){
dataSetRow["verkaeufer"] = pferd.getVerkaeufer().getName() + " " + pferd.getVerkaeufer().getVorname() + ", " +pferd.getVerkaeufer().getPlz()+ " " + pferd.getVerkaeufer().getOrt();
}
if(pferd.getZuechter()!= null){
dataSetRow["zuechter"] = pferd.getZuechter().getName() + " " + pferd.getZuechter().getVorname() + ", " +pferd.getZuechter().getPlz()+ " " + pferd.getZuechter().getOrt();
}
dataSetRow["hohe"] = pferd.getHoehe();
dataSetRow["geburtsdatum"] = pferd.getGeburtstag();
Maybe like this Birt renders the report in another way or at another time? Do I really have to change the datasource?
JasonW
The code you have should not matter what the datasource is. If you are using the apis, first do a run task and then a render task, not a runandrender task.
Jason
Connae
Thanks Jason, but I gave it up now.
I changed my datasource but this was not the problem. It work as long as I used only one "row per row", that meens, no data below another data in one cell. But as I need 4, birt increases my pagenumber only every 4th page. The first 4 pages have the number 11, the next for have number 12 aso... It seems that it allways worked like this but I didn't realize as I never had more than 3 pages.
JasonW
How were you running the reports? Using the APIs or the Viewer?
Connae
Tried both, doesn't mather...