| Summary: | IReportContext.getPageVariable("pageNumber") returns the wrong value | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Ghislain Gadbois <ghigad> |
| Component: | BIRT | Assignee: | Birt-ReportEngine-inbox <Birt-ReportEngine-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ghigad, hustlg |
| Version: | 2.6.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Is there any chance that this will be fixed in a 2.6.x release? Thank you! 2.6.2 is released, currently there is no plan for 2.6.3. it had been fixed in 3.7.1. please refer to bug 350216 *** This bug has been marked as a duplicate of bug 350216 *** |
We needed to retreive the current page number from a Java Event Handler. We found that using IReportContext.getPageVariable("pageNumber") should return the right value, but it doesn't. Searching through the source code, we found out that this ends up calling org.eclipse.birt.report.engine.executor.ExecutionContext.getPageVariable(String). Here is the code for this method... public Object getPageVariable( String name ) { if ( "totalPage".equals( name ) ) { return Long.valueOf( totalPage ); } if ( "pageNumber".equals( name ) ) { return Long.valueOf( totalPage ); } PageVariable var = pageVariables.get( name ); if ( var != null ) { return var.getValue( ); } return null; } You can clearly see that when "pageNumber".equals(name), it returns totalPage and not pageNumber as it should. We found a workaround by using IReportContext.evaluate("pageNumber;"), but it's not that elegant, given the performance loss caused by evaluating a Javascript expression. Thank you for your help!