How to change Master Page size onFetch of data set. [message #933056] |
Thu, 04 October 2012 17:39 |
Michael Wirzbicki 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 #934193 is a reply to message #934055] |
Fri, 05 October 2012 18:45 |
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02927 seconds