Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363055 - IReportContext.getPageVariable("pageNumber") returns the wrong value
Summary: IReportContext.getPageVariable("pageNumber") returns the wrong value
Status: CLOSED DUPLICATE of bug 350216
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.6.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Birt-ReportEngine-inbox@eclipse.org CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-07 10:24 EST by Ghislain Gadbois CLA
Modified: 2011-11-07 20:53 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ghislain Gadbois CLA 2011-11-07 10:24:23 EST
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!
Comment 1 Ghislain Gadbois CLA 2011-11-07 10:26:52 EST
Is there any chance that this will be fixed in a 2.6.x release?

Thank you!
Comment 2 Gang Liu CLA 2011-11-07 20:53:22 EST
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 ***