jpp74 Posted August 21, 2009 Share Posted August 21, 2009 Hi allI try to obtain the page number in a subreport, but when I evaluate variable PAGE_NUMBER I obtain the page in the current sub report and not in the global report, is there a solution to obtain the good page number value?Thanks for help Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 21, 2009 Share Posted August 21, 2009 Hi, You should pass the current page number from the master as parameter to the subreport and you'll add it to the subreports current page number.Note that evaluationTime does not work outside the subreport, so you would have troubles displaying the total number of pages in the master using text fields that are inside the subreport.This is why we always recommned putting the "page 1 of N" sequence in the page footer of the master, where it should be.You cannot have a subreport deal with the page footer of the master, because it cannot display master report level totals. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
jpp74 Posted August 21, 2009 Author Share Posted August 21, 2009 Thanks for your quickly response Teodord.For "page x" I added this information in page footer of my master report, it was ok. In fact I tried to generate a table of content with page number, like in tableofcontents sample.I also tried to pass PAGE_NUMBER in parameter of a subreport, in the subreport I retrieve the value 1, but this report appear at page 10 in the final report (it is precede by 2 sub reports). Below a piece of master report template, when I print the parameter pageOffset in the title section of the subreport, the value is 1.What's wrong, I don't understand.Thanks for helpCode:<subreport isUsingCache="false"> <reportElement x="0" y="151" width="535" height="71" key="subreport-2" positionType="Float"/> <parametersMapExpression><![CDATA[$P{sousRapportsParamMap}.get("PRES_GENE_INVEST_REPORT")]]></parametersMapExpression> <subreportParameter name="pageOffset"> <subreportParameterExpression><![CDATA[$V{PAGE_NUMBER}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[$P{sousRapportsDsMap}.get("PRES_GENE_INVEST_REPORT")]]></dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{sousRapportsMap}.get("PRES_GENE_INVEST_REPORT")]]></subreportExpression></subreport> Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 21, 2009 Share Posted August 21, 2009 Hi, And what is the expression of the text field showing the page number in the subreport? Thank you,Teodor Link to comment Share on other sites More sharing options...
jpp74 Posted September 14, 2009 Author Share Posted September 14, 2009 Hi Teodor,Sorry for the late response (I was on holidays)I send you the piece of jasper template for the sub report where I try to display the page number in the title section.Thanks for help.Jean-PaulCode:<title> <band height="89" isSplitAllowed="true" > ... <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="43" y="60" width="82" height="25" key="textField-1"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["page" + $P{pageOffset}.toString()]]></textFieldExpression> </textField> </band></title> Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 14, 2009 Share Posted September 14, 2009 Hi, You would have to post here the complete JRXML files involved and not only pieces of it.I assume you subreport is actually part of a huge band that has something else before the subreport.This huge band spans 10 pages before your subreport starts. The trouble is that the subreport element expressions are evaluated at the time the band fill starts and page number is 1. They do not get re-evaluated when the subreport starts. Depending on what you want to achieve, there are solutions for this, but we need to see all the files to understand what you are doing.If my above assumption is correct, you would have to isolate the subreport in its own separate band. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
jpp74 Posted September 14, 2009 Author Share Posted September 14, 2009 Hi,I haven't joined all the jrxml files because there is a lot, I have just joined all reports before the report who display PAGE_NUMBER variable.In my example that I sent to you, to do a test I print the page number in the sub report PresGeneInvestChapitre.jrxml (PRES_GENE_INVEST_REPORT).In fact I would like to store the page number of chapters in my document, I do this by a call to the scriptlet in sub report PresGeneBudgetDepInvest.jrxml (PRES_GENE_INVEST_DEP_REPORT),when I test the parameter value receive in "marqueEntree" method, I have the value 1. Then in the sub report Sommaire.jrxml (SOMMAIRE_REPORT), I would like to retrieve the value stored by scriptlet, to display the page number of the differents chapters. Below the sub reports treeM14.jrxml is the master report VueEnsemble.jrxml (PRES_GENE_VUE_ENS_REPORT sub report) PresGeneFctChapitre.jrxml (PRES_GENE_FCT_REPORT) PresGeneBudgetDepFct.jrxml (PRES_GENE_FCT_DEP_REPORT) PresGeneBalanceRecFct.jrxml (PRES_GENE_FCT_REC_REPORT) PresGeneInvestChapitre.jrxml (PRES_GENE_INVEST_REPORT) PresGeneBudgetDepInvest.jrxml (PRES_GENE_INVEST_DEP_REPORT) PresGeneBudgetRecInvest.jrxml(PRES_GENE_INVEST_REC_REPORT) .... Sommaire.jrxml (SOMMAIRE_REPORT) Thanks for helpJean-Paul Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now