Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to change Master Page size onFetch of data set.(Master Page Size change.)
How to change Master Page size onFetch of data set. [message #933056] Thu, 04 October 2012 17:39 Go to next message
Michael Wirzbicki is currently offline Michael WirzbickiFriend
Messages: 9
Registered: December 2011
Junior Member
Greetings all,

Were using BIRT 3.7.2(Eclipse), Oracle 10g, JBOSS 4.2, java 1.6

Problem: Trying to change Master Page witdh from 11in to either 20in, 30in depending on number of columns.

I have been successfull in changing size using the beforeRender event but I don't have any databack from the dataset to determine number of columns.

I tried executing the same java code on the dataset onFetch event but it has no effect on the report generation/presentation. I have to admit I am vague on what I can or cannot do on certain events because I don't have a firm understanding of them all. beforeRender event does occur before my onFetch of the dataset but the java code i'm using doesn't work at that point.

Thanks in advance to all those who comment!

Mike W.


Java code used in the beforeRender event that works:

// Control size of table and page based upon output being rendered
//
//
var roption reportContext.getRenderOption).outputFormat; // Render Option
var twidth = reportContext.getDesignHandle().getElementByID(2194).getPropertyHandle("width").value; // Table width
var pwidth = reportContext.getDesignHandle().getMasterPages().get(0).getProperty("width"); // Master Page width

// See which render type we're running for
if (roption == "xls") {
// xcell width setting
var nsize = "30in";
reportContext.getDesignHandle().getElementByID(2194).setProperty("width", "100%");
reportContext.getDesignHandle().getMasterPages().get(0).setProperty("width", nsize);
}
else {
// Standard setting..
//reportContext.getDesignHandle().getElementByID(2194).setProperty("width", "10in");
reportContext.getDesignHandle().getMasterPages().get(0).setProperty("width", "11in");
};

pwidth = reportContext.getDesignHandle().getMasterPages().get(0).getProperty("width");
//...... Ending
Re: How to change Master Page size onFetch of data set. [message #933988 is a reply to message #933056] Fri, 05 October 2012 14:36 Go to previous messageGo to next message
Michael Wirzbicki is currently offline Michael WirzbickiFriend
Messages: 9
Registered: December 2011
Junior Member
Greetings,

From reading various threads on this topic it appears that only events beforeRender, or beforeFactory is when you can change master page size.

Is this true?

Also a technique mention to get around doing it on a dataset event onFetch is to use 2 report design files, one to get data to fiqure out the number of rows or columns (as in my case). Then the other design file to generate the report.

Is this true also?

So again I'll ask the question in another way: Other than a beforeRender or beforeFactory event is there any other events where I can change the masterpage size?


Thank-you all in advance!
Mike W
Re: How to change Master Page size onFetch of data set. [message #934055 is a reply to message #933988] Fri, 05 October 2012 16:02 Go to previous messageGo to next message
Michael Wirzbicki is currently offline Michael WirzbickiFriend
Messages: 9
Registered: December 2011
Junior Member
One other fact... I can on a dataset onFetch event change the master page width to 30 using the java script
reportContext.getDesignHandle().findMasterPage('Simple MasterPage').setProperty('width', '30in');

But because I believe birt has already used the master page to create the inital report is has no effect on the output at this point. I do verify that change has taken effect on the master page because I interrogate it after the call and I see it return value is now '30in' where it previously '11in'.

var mwidth = reportContext.getDesignHandle().getMasterPages().get(0).getProperty("width");


I had thought this java getReportrunnable() method below would have worked but it had not effect.

reportContext.getReportRunnable().getDesignInstance().setUserProperty('width', '30in');


regards,
Mike W.
Re: How to change Master Page size onFetch of data set. [message #934193 is a reply to message #934055] Fri, 05 October 2012 18:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Are you using a runandrender task or a run task followed by a render task. One approach is to leave the code in the beforeFactory and call the birt data engine to execute a data set and use it to make your decision.

For example, if my decision was based on rowcount I would use the following script.

importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage(Packages.java.lang);
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.data.engine.api);
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.data.engine.api.querydefn);
importPackage(Packages.org.eclipse.birt.data.engine.core);


var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();
var de = DataEngine.newDataEngine( myconfig, null );

var dsrc = reportContext.getDesignHandle().findDataSource("Data Source");
var dset = reportContext.getDesignHandle().findDataSet("Data Set");

var odaDataSource = new OdaDataSourceDesign( "Test Data Source" );
odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );
odaDataSource.addPublicProperty( "odaURL", dsrc.getProperty("odaURL").toString() );
odaDataSource.addPublicProperty( "odaDriverClass", dsrc.getProperty("odaDriverClass").toString());
odaDataSource.addPublicProperty( "odaUser", dsrc.getProperty("odaUser").toString() );
odaDataSource.addPublicProperty( "odaPassword", "" );


var odaDataSet = new OdaDataSetDesign( "Test Data Set" );
odaDataSet.setDataSource( odaDataSource.getName( ) );
odaDataSet.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
odaDataSet.setQueryText( dset.getQueryText() );


de.defineDataSource( odaDataSource );
de.defineDataSet( odaDataSet );

queryDefinition = new QueryDefinition( );
queryDefinition.setDataSetName( odaDataSet.getName() );
queryDefinition.setAutoBinding(true);


var pq = de.prepare( queryDefinition );

var qr = pq.execute( null );

rowcount=0;
var ri = qr.getResultIterator( );
while ( ri.next( ) )
{
rowcount++
}

ri.close( );
qr.close( );
de.shutdown( );

Jason
Re: How to change Master Page size onFetch of data set. [message #934320 is a reply to message #934193] Fri, 05 October 2012 21:31 Go to previous messageGo to next message
Michael Wirzbicki is currently offline Michael WirzbickiFriend
Messages: 9
Registered: December 2011
Junior Member
Jason,

thanks for your reply... to clarify are you saying that place all java code above within the beforeFactory event in the desgin file or this is outside within the a given application (say web server)?

thanks again!
Mike W.
Re: How to change Master Page size onFetch of data set. [message #937316 is a reply to message #934320] Mon, 08 October 2012 22:06 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike

That is script you can call in the beforeFactory to execute a dataset before the report runs. It is just an example.

Jason
Previous Topic:Problem when generating dynamic tables
Next Topic:Viewer in non-RCP application
Goto Forum:
  


Current Time: Thu Apr 25 21:52:56 GMT 2024

Powered by FUDForum. Page generated in 0.03599 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top