Skip to main content



      Home
Home » Archived » BIRT » HELP!! BIRT Servlet cannot run more than once
HELP!! BIRT Servlet cannot run more than once [message #249895] Wed, 25 July 2007 21:37 Go to next message
Eclipse UserFriend
Originally posted by: jeremydorall.yahoo.com

Hello guys,

I'm a bit in a fix right now. I've compiled the following code in my
windows xp pc. Basically, what this code does is that it generates a new
rptdesign file based on the parameters received from the user. Now here's
the weird part. If i run the following servlet for the first time, it will
work, but if i were to run it again, then it wont. It seems as though the
previous session has been locked.What could be the problem? Could someone
please help me out with this??
Thanks a lot!!

Here's the code :

import java.io.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

import java.util.ArrayList;

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.model.api.CellHandle;
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.RowHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.TableHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException ;
import
org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;

import com.ibm.icu.util.ULocale;


public class testservlet extends HttpServlet
{

/**
*
*/
private static final long serialVersionUID = 1L;
ReportDesignHandle designHandle = null;
ElementFactory designFactory = null;
StructureFactory structFactory = null;
public ArrayList al = new ArrayList();
public Date date = new Date();
public SimpleDateFormat simpledate = null;

protected void doGet(HttpServletRequest
request,HttpServletResponse response)
throws ServletException,IOException
{

int i;
String queryString;
String strTable;
PrintWriter out = response.getWriter();

try
{
//Code to go through the parameters sent over
queryString = request.getParameter("txtSelect");
strTable = request.getParameter("txtFrom");
strTable = "From " + strTable;
//out.println(fieldarray.length);

//Parse the query sent over and place it in an
array
out.println(queryString);
parseQuery(queryString);

buildReport(al, strTable );
}
catch ( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( SemanticException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}

}

void parseQuery(String queryString)
{

String[] strArray = null;
strArray = new String[100];
char c;
String str2 = "";
int x=0;


for(int i=0;i<queryString.length();i++)
{
c =queryString.charAt(i);

if (i == queryString.length() - 1)
{
str2=str2 + c;
strArray[x] = str2;

}
else
{
if (c == ',')
{
strArray[x] = str2;
//System.out.println(str2);
str2="";
x++;

}
else
{
str2 = str2 + c;

}

}
}

for(int y=0;y < strArray.length ;y++)
{
if(strArray[y]==null)
{
break;
}
else
{
//System.out.println(strArray[y]);

al.add(strArray[y]);
}

}
}



void buildDataSource( ) throws SemanticException
{

OdaDataSourceHandle dsHandle =
designFactory.newOdaDataSource(
"Data Source",
"org.eclipse.birt.report.data.oda.jdbc" );
dsHandle.setProperty( "odaDriverClass",
"com.mysql.jdbc.Driver" );
dsHandle.setProperty( "odaURL",
"jdbc:mysql://localhost/test" );
dsHandle.setProperty( "odaUser", "root" );
dsHandle.setProperty( "odaPassword", "*****" );

designHandle.getDataSources( ).add( dsHandle );

}

void buildDataSet(ArrayList cols, String fromClause ) throws
SemanticException
{

//This is where the query will be built

OdaDataSetHandle dsHandle = designFactory.newOdaDataSet(
"ds",

"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource( "Data Source" );
String qry = "Select ";
for( int i=0; i < cols.size(); i++){
qry += " " + cols.get(i);
if( i != (cols.size() -1) ){
qry += ",";
}

}
qry += " " + fromClause;

dsHandle.setQueryText( qry );

designHandle.getDataSets( ).add( dsHandle );



}
void buildReport(ArrayList cols, String fromClause ) throws
IOException, SemanticException
{

//Configure the Engine and start the Platform
DesignConfig config = new DesignConfig( );

//Need to change the property here
//For Linux
config.setProperty("BIRT_HOME",
"/home/jcd/BIRT/birt-runtime-2_1_2/ReportEngine/");

//For Windows
//config.setProperty("BIRT_HOME", "C:/Documents and
Settings/jcd/My Documents/Jeremy_backup on Cljcd on pc
(Clhcw)/ALM/BIRT/birt-runtime-2_1_2/ReportEngine");
IDesignEngine engine = null;
try{


Platform.startup( config );
IDesignEngineFactory factory =
(IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );

}catch( Exception ex){
ex.printStackTrace();
}


SessionHandle session = engine.newSessionHandle(
ULocale.ENGLISH ) ;



try{
//open a design or a template
//Need to change the property here
//For Linux //
//designHandle =
session.openDesign("/opt/tomcat/webapps/ALM/new_report_1.rptdesign ");
designHandle = session.createDesign();
//For Windows
//designHandle = session.openDesign("C:/Program
Files/Apache Software Foundation/Tomcat
6.0/webapps/testjsp/new_report_1.rptdesign");
designFactory = designHandle.getElementFactory( );

buildDataSource();
buildDataSet(cols, fromClause);


TableHandle table = designFactory.newTableItem(
"table", cols.size() );
table.setWidth( "100%" );
table.setDataSet( designHandle.findDataSet( "ds" ) );

PropertyHandle computedSet = table.getColumnBindings( );
ComputedColumn cs1 = null;

for( int i=0; i < cols.size(); i++){
cs1 =
StructureFactory.createComputedColumn();
cs1.setName((String)cols.get(i));
cs1.setExpression("dataSetRow[\"" +
(String)cols.get(i) + "\"]");
computedSet.addItem(cs1);
}


// table header
RowHandle tableheader = (RowHandle)
table.getHeader( ).get( 0 );


for( int i=0; i < cols.size(); i++){
LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
label1.setText((String)cols.get(i));
CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
cell.getContent( ).add( label1 );
}

// table detail
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
for( int i=0; i < cols.size(); i++){
CellHandle cell = (CellHandle)
tabledetail.getCells( ).get( i );
DataItemHandle data = designFactory.newDataItem(
"data_"+(String)cols.get(i) );
data.setResultSetColumn( (String)cols.get(i));
cell.getContent( ).add( data );
}

designHandle.getBody( ).add( table );

// Save the design and close it.

//First, make the filename unique by naming it by the datetime

simpledate = new SimpleDateFormat("yyyyMMddkkmmss");


//Need to change the property here

//For Linux

designHandle.saveAs( "/opt/tomcat/webapps/WebViewerExample/" +
simpledate.format(date) + ".rptdesign" ); //$NON-NLS-1$

//For Windows
//designHandle.saveAs( "C:/Program Files/Apache Software
Foundation/Tomcat 6.0/webapps/birt-viewer/report.rptdesign" );
//$NON-NLS-1$

designHandle.close( );



}catch (Exception e){
e.printStackTrace();
}

}





}
Re: HELP!! BIRT Servlet cannot run more than once [message #250003 is a reply to message #249895] Thu, 26 July 2007 08:18 Go to previous messageGo to next message
Eclipse UserFriend
Jeremy,

You have called Platform.startup(), but you haven't called
Platform.shutdown()

Snjeza

Jeremy wrote:
> Hello guys,
> I'm a bit in a fix right now. I've compiled the following code in my
> windows xp pc. Basically, what this code does is that it generates a new
> rptdesign file based on the parameters received from the user. Now
> here's the weird part. If i run the following servlet for the first
> time, it will work, but if i were to run it again, then it wont. It
> seems as though the previous session has been locked.What could be the
> problem? Could someone please help me out with this?? Thanks a lot!!
> Here's the code :
> import java.io.*; import java.util.*; import java.util.Date; import
> java.text.*; import java.sql.*; import javax.servlet.*; import
> javax.servlet.http.*; import java.io.IOException; import
> java.io.PrintWriter;
> import java.util.ArrayList;
> import org.eclipse.birt.core.framework.Platform; import
> org.eclipse.birt.report.engine.api.IReportEngine; import
> org.eclipse.birt.report.model.api.CellHandle; import
> org.eclipse.birt.report.model.api.DataItemHandle; import
> org.eclipse.birt.report.model.api.DesignConfig; import
> org.eclipse.birt.report.model.api.ElementFactory; import
> org.eclipse.birt.report.model.api.IDesignEngine; import
> org.eclipse.birt.report.model.api.IDesignEngineFactory; import
> org.eclipse.birt.report.model.api.LabelHandle; import
> org.eclipse.birt.report.model.api.OdaDataSetHandle; import
> org.eclipse.birt.report.model.api.OdaDataSourceHandle; import
> org.eclipse.birt.report.model.api.PropertyHandle; import
> org.eclipse.birt.report.model.api.ReportDesignHandle; import
> org.eclipse.birt.report.model.api.RowHandle; import
> org.eclipse.birt.report.model.api.SessionHandle; import
> org.eclipse.birt.report.model.api.StructureFactory; import
> org.eclipse.birt.report.model.api.TableHandle; import
> org.eclipse.birt.report.model.api.activity.SemanticException ; import
> org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;
> import com.ibm.icu.util.ULocale;
>
> public class testservlet extends HttpServlet { /**
> * */ private static final long serialVersionUID = 1L;
> ReportDesignHandle designHandle = null; ElementFactory
> designFactory = null; StructureFactory structFactory = null;
> public ArrayList al = new ArrayList(); public Date date =
> new Date(); public SimpleDateFormat simpledate = null;
> protected void doGet(HttpServletRequest
> request,HttpServletResponse response) throws
> ServletException,IOException { int i;
> String queryString; String strTable;
> PrintWriter out = response.getWriter();
> try {
> //Code to go through the parameters sent over
> queryString = request.getParameter("txtSelect");
> strTable = request.getParameter("txtFrom");
> strTable = "From " + strTable;
> //out.println(fieldarray.length);
>
> //Parse the query sent over and place it in an array
> out.println(queryString);
> parseQuery(queryString);
> buildReport(al, strTable ); }
> catch ( IOException e ) {
> // TODO Auto-generated catch block
> e.printStackTrace(); }
> catch ( SemanticException e ) {
> // TODO Auto-generated catch block
> e.printStackTrace(); }
> } void parseQuery(String
> queryString) { String[] strArray = null; strArray = new
> String[100]; char c; String str2 = "";
> int x=0;
> for(int i=0;i<queryString.length();i++) {
> c =queryString.charAt(i);
> if (i == queryString.length() - 1)
> { str2=str2 + c;
> strArray[x] = str2;
> }
> else {
> if (c == ',') {
> strArray[x] = str2;
> //System.out.println(str2);
> str2="";
> x++; }
> else {
> str2 = str2 + c;
> }
> } }
> for(int y=0;y < strArray.length ;y++)
> { if(strArray[y]==null)
> { break;
> } else
> {
> //System.out.println(strArray[y]);
> al.add(strArray[y]);
> } }
> } void buildDataSource( ) throws
> SemanticException {
> OdaDataSourceHandle dsHandle =
> designFactory.newOdaDataSource( "Data
> Source", "org.eclipse.birt.report.data.oda.jdbc" );
> dsHandle.setProperty( "odaDriverClass",
> "com.mysql.jdbc.Driver" ); dsHandle.setProperty(
> "odaURL", "jdbc:mysql://localhost/test" );
> dsHandle.setProperty( "odaUser", "root" );
> dsHandle.setProperty( "odaPassword", "*****" );
> designHandle.getDataSources( ).add( dsHandle );
> }
> void buildDataSet(ArrayList cols, String fromClause ) throws
> SemanticException {
> //This is where the query will be built
> OdaDataSetHandle dsHandle = designFactory.newOdaDataSet(
> "ds",
> "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
> dsHandle.setDataSource( "Data Source" );
> String qry = "Select "; for( int i=0; i < cols.size();
> i++){ qry += " " + cols.get(i);
> if( i != (cols.size() -1) ){
> qry += ","; }
> } qry += " " +
> fromClause; dsHandle.setQueryText( qry );
> designHandle.getDataSets( ).add( dsHandle );
>
> } void buildReport(ArrayList cols, String
> fromClause ) throws IOException, SemanticException {
> //Configure the Engine and
> start the Platform DesignConfig config = new
> DesignConfig( );
> //Need to change the property here //For
> Linux config.setProperty("BIRT_HOME",
> "/home/jcd/BIRT/birt-runtime-2_1_2/ReportEngine/");
> //For Windows
> //config.setProperty("BIRT_HOME", "C:/Documents and Settings/jcd/My
> Documents/Jeremy_backup on Cljcd on pc
> (Clhcw)/ALM/BIRT/birt-runtime-2_1_2/ReportEngine"); IDesignEngine
> engine = null; try{
>
> Platform.startup( config );
> IDesignEngineFactory factory =
> (IDesignEngineFactory) Platform
> .createFactoryObject(
> IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
> engine = factory.createDesignEngine( config );
> }catch( Exception ex){ ex.printStackTrace();
> }
>
> SessionHandle session = engine.newSessionHandle(
> ULocale.ENGLISH ) ;
>
> try{ //open a design or a template
> //Need to change the property here
> //For Linux //
> //designHandle =
> session.openDesign("/opt/tomcat/webapps/ALM/new_report_1.rptdesign ");
> designHandle = session.createDesign();
> //For Windows
> //designHandle = session.openDesign("C:/Program Files/Apache Software
> Foundation/Tomcat 6.0/webapps/testjsp/new_report_1.rptdesign");
> designFactory = designHandle.getElementFactory( );
> buildDataSource(); buildDataSet(cols,
> fromClause);
>
> TableHandle table = designFactory.newTableItem(
> "table", cols.size() ); table.setWidth( "100%" );
> table.setDataSet( designHandle.findDataSet( "ds" ) );
> PropertyHandle computedSet = table.getColumnBindings( );
> ComputedColumn cs1 = null;
> for( int i=0; i < cols.size(); i++){
> cs1 =
> StructureFactory.createComputedColumn();
> cs1.setName((String)cols.get(i));
> cs1.setExpression("dataSetRow[\"" + (String)cols.get(i) + "\"]");
> computedSet.addItem(cs1);
> }
> // table header RowHandle
> tableheader = (RowHandle) table.getHeader( ).get( 0 );
>
> for( int i=0; i < cols.size(); i++){ LabelHandle label1 =
> designFactory.newLabel( (String)cols.get(i) );
> label1.setText((String)cols.get(i)); CellHandle cell = (CellHandle)
> tableheader.getCells( ).get( i ); cell.getContent( ).add( label1 );
> }
> // table detail RowHandle tabledetail = (RowHandle) table.getDetail(
> ).get( 0 ); for( int i=0; i < cols.size(); i++){
> CellHandle cell = (CellHandle)
> tabledetail.getCells( ).get( i ); DataItemHandle data =
> designFactory.newDataItem( "data_"+(String)cols.get(i) );
> data.setResultSetColumn( (String)cols.get(i)); cell.getContent(
> ).add( data ); }
> designHandle.getBody( ).add( table );
> // Save the design and close it.
> //First, make the filename unique by naming it by the datetime
> simpledate = new SimpleDateFormat("yyyyMMddkkmmss");
>
> //Need to change the property here
> //For Linux
> designHandle.saveAs( "/opt/tomcat/webapps/WebViewerExample/" +
> simpledate.format(date) + ".rptdesign" ); //$NON-NLS-1$
> //For Windows //designHandle.saveAs(
> "C:/Program Files/Apache Software Foundation/Tomcat
> 6.0/webapps/birt-viewer/report.rptdesign" ); //$NON-NLS-1$
> designHandle.close( );
>
> }catch (Exception e){
> e.printStackTrace(); }
> } }
>
>
>
Re: HELP!! BIRT Servlet cannot run more than once [message #250293 is a reply to message #250003] Sun, 29 July 2007 23:16 Go to previous message
Eclipse UserFriend
Originally posted by: jeremydorall.yahoo.com

Snjeza

I've added the Platform.shutdown() command at the end of my code, but
unfortunately, it still doenst work. Im at wits end trying to solve this
issue.
Arghhh!!

Anyway, thanks for your suggestion Snjeza. Really appreatiate it

Jeremy

Snjezana Peco wrote:

> Jeremy,

> You have called Platform.startup(), but you haven't called
> Platform.shutdown()

> Snjeza

> Jeremy wrote:
>> Hello guys,
>> I'm a bit in a fix right now. I've compiled the following code in my
>> windows xp pc. Basically, what this code does is that it generates a new
>> rptdesign file based on the parameters received from the user. Now
>> here's the weird part. If i run the following servlet for the first
>> time, it will work, but if i were to run it again, then it wont. It
>> seems as though the previous session has been locked.What could be the
>> problem? Could someone please help me out with this?? Thanks a lot!!
>> Here's the code :
>> import java.io.*; import java.util.*; import java.util.Date; import
>> java.text.*; import java.sql.*; import javax.servlet.*; import
>> javax.servlet.http.*; import java.io.IOException; import
>> java.io.PrintWriter;
>> import java.util.ArrayList;
>> import org.eclipse.birt.core.framework.Platform; import
>> org.eclipse.birt.report.engine.api.IReportEngine; import
>> org.eclipse.birt.report.model.api.CellHandle; import
>> org.eclipse.birt.report.model.api.DataItemHandle; import
>> org.eclipse.birt.report.model.api.DesignConfig; import
>> org.eclipse.birt.report.model.api.ElementFactory; import
>> org.eclipse.birt.report.model.api.IDesignEngine; import
>> org.eclipse.birt.report.model.api.IDesignEngineFactory; import
>> org.eclipse.birt.report.model.api.LabelHandle; import
>> org.eclipse.birt.report.model.api.OdaDataSetHandle; import
>> org.eclipse.birt.report.model.api.OdaDataSourceHandle; import
>> org.eclipse.birt.report.model.api.PropertyHandle; import
>> org.eclipse.birt.report.model.api.ReportDesignHandle; import
>> org.eclipse.birt.report.model.api.RowHandle; import
>> org.eclipse.birt.report.model.api.SessionHandle; import
>> org.eclipse.birt.report.model.api.StructureFactory; import
>> org.eclipse.birt.report.model.api.TableHandle; import
>> org.eclipse.birt.report.model.api.activity.SemanticException ; import
>> org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;
>> import com.ibm.icu.util.ULocale;
>>
>> public class testservlet extends HttpServlet { /**
>> * */ private static final long serialVersionUID = 1L;
>> ReportDesignHandle designHandle = null; ElementFactory
>> designFactory = null; StructureFactory structFactory = null;
>> public ArrayList al = new ArrayList(); public Date date =
>> new Date(); public SimpleDateFormat simpledate = null;
>> protected void doGet(HttpServletRequest
>> request,HttpServletResponse response) throws
>> ServletException,IOException { int i;
>> String queryString; String strTable;
>> PrintWriter out = response.getWriter();
>> try {
>> //Code to go through the parameters sent over
>> queryString = request.getParameter("txtSelect");
>> strTable = request.getParameter("txtFrom");
>> strTable = "From " + strTable;
>> //out.println(fieldarray.length);
>>
>> //Parse the query sent over and place it in an array
>> out.println(queryString);
>> parseQuery(queryString);
>> buildReport(al, strTable ); }
>> catch ( IOException e ) {
>> // TODO Auto-generated catch block
>> e.printStackTrace(); }
>> catch ( SemanticException e ) {
>> // TODO Auto-generated catch block
>> e.printStackTrace(); }
>> } void parseQuery(String
>> queryString) { String[] strArray = null; strArray = new
>> String[100]; char c; String str2 = "";
>> int x=0;
>> for(int i=0;i<queryString.length();i++) {
>> c =queryString.charAt(i);
>> if (i == queryString.length() - 1)
>> { str2=str2 + c;
>> strArray[x] = str2;
>> }
>> else {
>> if (c == ',') {
>> strArray[x] = str2;
>> //System.out.println(str2);
>> str2="";
>> x++; }
>> else {
>> str2 = str2 + c;
>> }
>> } }
>> for(int y=0;y < strArray.length ;y++)
>> { if(strArray[y]==null)
>> { break;
>> } else
>> {
>> //System.out.println(strArray[y]);
>> al.add(strArray[y]);
>> } }
>> } void buildDataSource( ) throws
>> SemanticException {
>> OdaDataSourceHandle dsHandle =
>> designFactory.newOdaDataSource( "Data
>> Source", "org.eclipse.birt.report.data.oda.jdbc" );
>> dsHandle.setProperty( "odaDriverClass",
>> "com.mysql.jdbc.Driver" ); dsHandle.setProperty(
>> "odaURL", "jdbc:mysql://localhost/test" );
>> dsHandle.setProperty( "odaUser", "root" );
>> dsHandle.setProperty( "odaPassword", "*****" );
>> designHandle.getDataSources( ).add( dsHandle );
>> }
>> void buildDataSet(ArrayList cols, String fromClause ) throws
>> SemanticException {
>> //This is where the query will be built
>> OdaDataSetHandle dsHandle = designFactory.newOdaDataSet(
>> "ds",
>> "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
>> dsHandle.setDataSource( "Data Source" );
>> String qry = "Select "; for( int i=0; i < cols.size();
>> i++){ qry += " " + cols.get(i);
>> if( i != (cols.size() -1) ){
>> qry += ","; }
>> } qry += " " +
>> fromClause; dsHandle.setQueryText( qry );
>> designHandle.getDataSets( ).add( dsHandle );
>>
>> } void buildReport(ArrayList cols, String
>> fromClause ) throws IOException, SemanticException {
>> //Configure the Engine and
>> start the Platform DesignConfig config = new
>> DesignConfig( );
>> //Need to change the property here //For
>> Linux config.setProperty("BIRT_HOME",
>> "/home/jcd/BIRT/birt-runtime-2_1_2/ReportEngine/");
>> //For Windows
>> //config.setProperty("BIRT_HOME", "C:/Documents and Settings/jcd/My
>> Documents/Jeremy_backup on Cljcd on pc
>> (Clhcw)/ALM/BIRT/birt-runtime-2_1_2/ReportEngine"); IDesignEngine
>> engine = null; try{
>>
>> Platform.startup( config );
>> IDesignEngineFactory factory =
>> (IDesignEngineFactory) Platform
>> .createFactoryObject(
>> IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
>> engine = factory.createDesignEngine( config );
>> }catch( Exception ex){ ex.printStackTrace();
>> }
>>
>> SessionHandle session = engine.newSessionHandle(
>> ULocale.ENGLISH ) ;
>>
>> try{ //open a design or a template
>> //Need to change the property here
>> //For Linux //
>> //designHandle =
>> session.openDesign("/opt/tomcat/webapps/ALM/new_report_1.rptdesign ");
>> designHandle = session.createDesign();
>> //For Windows
>> //designHandle = session.openDesign("C:/Program Files/Apache Software
>> Foundation/Tomcat 6.0/webapps/testjsp/new_report_1.rptdesign");
>> designFactory = designHandle.getElementFactory( );
>> buildDataSource(); buildDataSet(cols,
>> fromClause);
>>
>> TableHandle table = designFactory.newTableItem(
>> "table", cols.size() ); table.setWidth( "100%" );
>> table.setDataSet( designHandle.findDataSet( "ds" ) );
>> PropertyHandle computedSet = table.getColumnBindings( );
>> ComputedColumn cs1 = null;
>> for( int i=0; i < cols.size(); i++){
>> cs1 =
>> StructureFactory.createComputedColumn();
>> cs1.setName((String)cols.get(i));
>> cs1.setExpression("dataSetRow["" + (String)cols.get(i) + ""]");
>> computedSet.addItem(cs1);
>> }
>> // table header RowHandle
>> tableheader = (RowHandle) table.getHeader( ).get( 0 );
>>
>> for( int i=0; i < cols.size(); i++){ LabelHandle label1 =
>> designFactory.newLabel( (String)cols.get(i) );
>> label1.setText((String)cols.get(i)); CellHandle cell = (CellHandle)
>> tableheader.getCells( ).get( i ); cell.getContent( ).add( label1 );
>> }
>> // table detail RowHandle tabledetail = (RowHandle) table.getDetail(
>> ).get( 0 ); for( int i=0; i < cols.size(); i++){
>> CellHandle cell = (CellHandle)
>> tabledetail.getCells( ).get( i ); DataItemHandle data =
>> designFactory.newDataItem( "data_"+(String)cols.get(i) );
>> data.setResultSetColumn( (String)cols.get(i)); cell.getContent(
>> ).add( data ); }
>> designHandle.getBody( ).add( table );
>> // Save the design and close it.
>> //First, make the filename unique by naming it by the datetime
>> simpledate = new SimpleDateFormat("yyyyMMddkkmmss");
>>
>> //Need to change the property here
>> //For Linux
>> designHandle.saveAs( "/opt/tomcat/webapps/WebViewerExample/" +
>> simpledate.format(date) + ".rptdesign" ); //$NON-NLS-1$
>> //For Windows //designHandle.saveAs(
>> "C:/Program Files/Apache Software Foundation/Tomcat
>> 6.0/webapps/birt-viewer/report.rptdesign" ); //$NON-NLS-1$
>> designHandle.close( );
>>
>> }catch (Exception e){
>> e.printStackTrace(); }
>> } }
>>
>>
>>
Previous Topic:problem when exporting to XLS
Next Topic:BIRT 2.2 Recommendations on JVM tuning parameters for Webapps embedding the reporting engine
Goto Forum:
  


Current Time: Wed May 07 05:18:24 EDT 2025

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

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

Back to the top