rsilverns.sympatico.ca Posted November 21, 2006 Share Posted November 21, 2006 Just wondering if anyone knows of a clean way to do a page numbering in format of "Page X of Y"? I am able to do it currently by having two expressions, "Page X of" which gets evaluated at "now" and then "Y" which gets evaulated once at the end to calculate each page. Code:<textField> <reportElement x="390" y="6" width="99" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement x="489" y="6" width="15" height="20"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression> </textField> The problem is that it really makes aligning the page numbering hard since they are two text fields and the total page count could grow considerably depending on the data set. I would like to know if anyone knows of tricks for how to best create this page numbering? I would like to have a smooth spacing and alignment of "Page X of Y" so that I could right align the entire thing on the right side of my page at the right margin... and have it grow to the left as needed (i.e. Page XX of YYY etc.) Thx,Robin Link to comment Share on other sites More sharing options...
lucianc Posted November 21, 2006 Share Posted November 21, 2006 Take a look at this solution, maybe you'll find it suitable. HTH,Lucian Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted November 22, 2006 Author Share Posted November 22, 2006 That fixed it.. nice trick guys! For those reading this post, as per lucianc's other post the solution was..... Code:<variable name="CurrPageNo" class="java.lang.Integer" resetType="Page"> <variableExpression>$V{PAGE_NUMBER}</variableExpression></variable>..<textField evaluationTime="Auto"> .. <textFieldExpression><![CDATA["Page " + $V{CurrPageNo} + " / " + $V{PAGE_NUMBER}]]></textFieldExpression></textField> Thanks,Robin Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted November 22, 2006 Author Share Posted November 22, 2006 I may have spoken too soon... this trick works for reports that do not have "Pages" introduced by the false group header trick, but when you do that the system breaks down and I have a "null" generated for each page except the last page for the X in Page X of Y. Am seeing an infinite loop introduced during report filling somehow. Not sure what is going on will attempt to debug it. Will add this as a feature request. Link to comment Share on other sites More sharing options...
lucianc Posted November 22, 2006 Share Posted November 22, 2006 I'm not sure what the "false group header trick" is. And what exactly happens? You mentioned that "the system breaks down", then that you get "null" instead of the current page, and then you said something about an infinite loop. Do you have a simple sample (or relevant JRXML fragment) that illustrates the issue? Regards,Lucian Link to comment Share on other sites More sharing options...
pcharlton Posted June 14, 2007 Share Posted June 14, 2007 I tried the "auto" evaluation approach described here. It works well for most of my reports. For one report that calls a subreport, I'm getting null a for the current page number. Any ideas how to fix? Thanks,Paul Link to comment Share on other sites More sharing options...
lucianc Posted June 14, 2007 Share Posted June 14, 2007 Do you have a reproducible case for this? Otherwise, I don't think anyone would understand what the problem is so nobody would be able to suggest a fix. Regards,Lucian 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