narasumas Posted October 2, 2008 Share Posted October 2, 2008 Hello,I can display "Page X / Y" without any problems, but I also want to hide this "Page X / Y" fields when the generated report is only one page length.Using <printWhenExpression><![CDATA[$V{PAGE_NUMBER} > 1]]></printWhenExpression> for the corresponding textfields is not working properly : it will always hide the fields on the first page whereas I of course want those fields to be displayed for reports that have more than one page. In fact, what I need is a way to set "evaluationTime" to "Report" for the printWhenExpression attribute. Is it possible ?If not, is there anyway of achieving this otherwise ?Thanks and regards :)Code: <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self"> <reportElement x="369" y="42" width="100" height="18" key="textField"> <printWhenExpression><![CDATA[$V{PAGE_NUMBER} > 1]]></printWhenExpression> </reportElement> <box/> <textElement textAlignment="Right"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " / "]]></textFieldExpression> </textField> Link to comment Share on other sites More sharing options...
C-Box Posted October 2, 2008 Share Posted October 2, 2008 You could add a dummyline at summary section in negative y value where you put a boolean flag to REPORT_PARAMETER_FLAG in its PrintWhenExpression e.g..new Boolean($P{REPORT_PARAMETER_MAP}.put("LastPageFlag",Boolean.TRUE)) In your printwhenexpression you must get this value and compare it against true.Something like this:new Boolean(!(Boolean.TRUE).equals($P{REPORT_PARAMETER_MAP}.get("LastPageFlag"))) (not tested but I did something similiar in former times when using carry overs)hthC-Box Link to comment Share on other sites More sharing options...
narasumas Posted October 3, 2008 Author Share Posted October 3, 2008 Thanks for the help :)I don't really understand your solution... You are suggesting to add a summary and set a "isLastPage" variable within this summary section, correct ? As the summary is always in the last page, I would just need to check if isLastPage variable is true before displaying my Page X/Y. I'm not sure that is what you were suggesting... But anyway I don't know how to set and get this isLastPage variable...Maybe you could be more specific ? :)PS : It would have been far simpler if we just had a variable always containing the total number of pages of the report... Link to comment Share on other sites More sharing options...
C-Box Posted October 3, 2008 Share Posted October 3, 2008 Well it's difficult to explain and something similiar was at the Jasper Tipps and Tricks page some years ago... so I have it just in mind as I can't find the Jasper explanation of this trick at the new homepage. But as I have had some free minutes right now. I do build you a sample.Just look at the JRXML ... there is a line at Summary section, where I put the LastPageNumber into the Report-Parameter-Map. At the normal PageFooter I just print the Page X / Y when the current PageNumber is not the LastPageNumber or if the PageNumber is bigger than 1 (to show it also at last page). I do attach some PDFs also to show how it works. Just try it out with iReport and run it without data (first PDF) and then with 100 dummy records (press shif while pression the blue button and enter 100) and see the result (second PDF) hthC-Box Link to comment Share on other sites More sharing options...
C-Box Posted October 3, 2008 Share Posted October 3, 2008 Ups... seems that the forum doesn't support such long file names...I do attach the PDFs again... regards C-Box Link to comment Share on other sites More sharing options...
C-Box Posted October 3, 2008 Share Posted October 3, 2008 CBoxWrote: Well it's difficult to explain and something similiar was at the Jasper Tipps and Tricks page some years ago... so I have it just in mind as I can't find the Jasper explanation of this trick at the new homepage. But as I have had some free minutes right now. I do build you a sample. Just look at the JRXML ... there is a line at Summary section, where I put the LastPageNumber into the Report-Parameter-Map. At the normal PageFooter I just print the Page X / Y when the current PageNumber is not the LastPageNumber or if the PageNumber is bigger than 1 (to show it also at last page). I do attach some PDFs also to show how it works. Just try it out with iReport and run it without data (first PDF) and then with 100 dummy records (press shift while pressing the blue button and enter 100) and see the result (second PDF) hth C-Box Link to comment Share on other sites More sharing options...
narasumas Posted October 6, 2008 Author Share Posted October 6, 2008 Thanks !I have tried your solution and it's working great !Thanks for the help :) Link to comment Share on other sites More sharing options...
stelek Posted March 17, 2010 Share Posted March 17, 2010 Hi,I'm facing the same problem now and I tried your solution and it works... but not in my case. I need to check for the last page in the "background" band and in this case it does not work anymore. Even if I modify your example by moving the TextFields to the "background" band, it stops working. Any idea why is that and how I could fix it? Or how I could detect the last page in a different way? And please don't tell me not to use "background" band. I have a really complicated case of reports with subreports and now I have to add a common information on all pages (no matter which subreport they come from) but the last one. "Background" seems perfect for this... except the detection of the last page. Please help... Link to comment Share on other sites More sharing options...
stelek Posted March 17, 2010 Share Posted March 17, 2010 Seems the problem is with the "evaluation time". If I change it from "now" to "page" it starts working but of course in this way you can only affect the content of the field and not its visiblity. I'll appreciate any other ideas... Link to comment Share on other sites More sharing options...
jwindberg Posted June 2, 2010 Share Posted June 2, 2010 Did you solve this? I'm trying to figure it out now myself. Thanks Link to comment Share on other sites More sharing options...
hadv Posted August 9, 2013 Share Posted August 9, 2013 Hi, How can i download your pdf file? Thank you Link to comment Share on other sites More sharing options...
hadv Posted August 9, 2013 Share Posted August 9, 2013 Hi, How did you do? I need it urgently; so could you please explain me more details? Thank you Link to comment Share on other sites More sharing options...
hadv Posted August 12, 2013 Share Posted August 12, 2013 Yep, I found the same problem. It's only have value when using the "evaluation time' as "report"; but the expression in printWhen be always evaluated "now" Do you have any solution for it? Thank you Link to comment Share on other sites More sharing options...
hadv Posted August 12, 2013 Share Posted August 12, 2013 I finish this problem with java code like moving the table of content from the last page to the first page of the report Link to comment Share on other sites More sharing options...
tomkast_1 Posted June 3, 2014 Share Posted June 3, 2014 I need to hide the page header band on the last page and I am facing this same problem. in this example, you see that the variable value changes as expected with evalaution time of page. but the printWhen for the band and for fields is not effected. Any ideas?: <?xml version="1.0" encoding="UTF-8"?> select * from users ]]></fieldDescription></p><p> </field></p><p> <pageHeader></p><p> <band height="23" splitType="Stretch"></p><p> <textField evaluationTime="Page"></p><p> <reportElement x="120" y="0" width="238" height="20"></p><p> <printWhenExpression><![CDATA[!$V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}</p><p> .get("LastPageNumber")) "please don't print on last page - page header" "last page variable is: " + $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}</p><p> .get("LastPageNumber")) "Page header" "last page variable is: " + $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}</p><p> .get("LastPageNumber")) $F{userName} !$V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}</p><p> .get("LastPageNumber")) "please don't print on last page - detail" new Boolean($P{REPORT_PARAMETERS_MAP}.put("LastPageNumber",</p><p> $V{PAGE_NUMBER})) "last page variable is: " + $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}</p><p> .get("LastPageNumber")) Link to comment Share on other sites More sharing options...
wandl Posted September 16, 2014 Share Posted September 16, 2014 Hey CBox, i have the discussed problem and it seems that your uploaded PDF file is not longer avbliable. Could you please upload the file again? Thanks a lot Link to comment Share on other sites More sharing options...
step-by-step Posted March 10, 2015 Share Posted March 10, 2015 Thanks a lot to C-Box, im spending a lot of time for finding a way to check is current page is a last page or not in the jasperreport expression. 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