Skip to main content



      Home
Home » Archived » BIRT » Own Birt Viewer, Read Param Default
Own Birt Viewer, Read Param Default [message #66745] Thu, 11 August 2005 05:40 Go to next message
Eclipse UserFriend
Originally posted by: ksc_puschkin.yahoo.de

Hi there,

I'm trying to write my own BIRT viewer for the web. The main idea is to
read the report parameters and prompt for input before any report is
shown. So I created a sample report with two parameters (not in a
parameter-group) and startet to write a java bean to only read the reports
parameters and der default values (I used mainly the example code from the
BIRT integration example page). But when I display the result I get the
correct parameter name but always a 'none' for the default value although
there is a default value.

Thats the interesting part of my report-design:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Written by Eclipse BIRT 1.0 -->
<report xmlns=" http://www.eclipse.org/birt/2005/design" version="2">
<property name="createdBy">Eclipse BIRT Designer Version 1.0.0 Build
&lt;20050718-0150></property>
<property name="units">in</property>
<list-property name="configVars">
<structure>
<property name="name">Kunden</property>
<property name="value">D%</property>
</structure>
<structure>
<property name="name">Country</property>
<property name="value">F%</property>
</structure>
</list-property>
<parameters>
<scalar-parameter name="Kunden">
<property name="dataType">string</property>
<property name="format">Unformatted</property>
<property name="controlType">text-box</property>
<expression name="defaultValue">'A%'</expression>
</scalar-parameter>
<scalar-parameter name="Country">
<text-property name="displayName">Land</text-property>
<property name="dataType">string</property>
<property name="format">Unformatted</property>
<property name="controlType">text-box</property>
<expression name="defaultValue">'U%'</expression>
</scalar-parameter>
</parameters>
----------------------

And here is the part of my java bean that writes all parameter infos into
an output variable:

public String getParams()
{
EngineConfig config = new EngineConfig( );
config.setEngineHome(" d:/eclipse/plugins/org.eclipse.birt.report.viewer_1.0.0/birt /WEB-INF "
);
ReportEngine engine = new ReportEngine( config );
IReportRunnable report = null;
try
{
report = engine.openReportDesign( file );
}
catch ( EngineException e ) //Fehler auffangen
{
error=( "Report " + file + " not found!\n" );
engine.destroy( );
return error;
}

//Here starts the part to get the parameter infos
IGetParameterDefinitionTask task =
engine.createGetParameterDefinitionTask( report );
Collection params = task.getParameterDefns( true );
if ( params.isEmpty() )
{
output=output+( "This report has no parameters.\n" );
}
Iterator iter = params.iterator( );
while ( iter.hasNext( ) )
{
IParameterDefnBase defn = (IParameterDefnBase) iter.next( );
IScalarParameterDefn param = (IScalarParameterDefn) defn;
output=output+ "<br>Parameter: " + param.getName( );
output=output+ "<br>Display Name: " + param.getDisplayName( ) ;
output=output+ "<br>Type: " + param.getDataType( ) ;
output=output+ "<br>Default Value: ";

// The default value is an expression. Evaluate it.
// Maybe here is an error?

Object value = task.getDefaultValue( param );
if (value == null)
{
value = "none";
}
else
{
value=value.toString( );
}
output=output+value;
}
---------------------
And ich get the following output:

Parameter: Kunden
Display Name: null
Type: 1
Default Value: none <---- SHOULD NOT BE 'none'!

Parameter: Country
Display Name: Land
Type: 1
Default Value: none <---- SHOULD NOT BE 'none'!
----------------------

I hope someone could help me. Thanks in advance.

Robert
Re: Own Birt Viewer, Read Param Default [message #67375 is a reply to message #66745] Thu, 11 August 2005 13:45 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

I had the same problem for a while.

Apparently, you need to call
task.evaluateDefaults(); before
Object value = task.getDefaultValue( param );


Regards,

Bart



On Thu, 11 Aug 2005 09:40:53 +0000, Robert wrote:

> Hi there,
>
> I'm trying to write my own BIRT viewer for the web. The main idea is to
> read the report parameters and prompt for input before any report is
> shown. So I created a sample report with two parameters (not in a
> parameter-group) and startet to write a java bean to only read the reports
> parameters and der default values (I used mainly the example code from the
> BIRT integration example page). But when I display the result I get the
> correct parameter name but always a 'none' for the default value although
> there is a default value.
>
> Thats the interesting part of my report-design:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Written by Eclipse BIRT 1.0 -->
> <report xmlns=" http://www.eclipse.org/birt/2005/design" version="2">
> <property name="createdBy">Eclipse BIRT Designer Version 1.0.0 Build
> &lt;20050718-0150></property>
> <property name="units">in</property>
> <list-property name="configVars">
> <structure>
> <property name="name">Kunden</property>
> <property name="value">D%</property>
> </structure>
> <structure>
> <property name="name">Country</property>
> <property name="value">F%</property>
> </structure>
> </list-property>
> <parameters>
> <scalar-parameter name="Kunden">
> <property name="dataType">string</property>
> <property name="format">Unformatted</property>
> <property name="controlType">text-box</property>
> <expression name="defaultValue">'A%'</expression>
> </scalar-parameter>
> <scalar-parameter name="Country">
> <text-property name="displayName">Land</text-property>
> <property name="dataType">string</property>
> <property name="format">Unformatted</property>
> <property name="controlType">text-box</property>
> <expression name="defaultValue">'U%'</expression>
> </scalar-parameter>
> </parameters>
> ----------------------
>
> And here is the part of my java bean that writes all parameter infos into
> an output variable:
>
> public String getParams()
> {
> EngineConfig config = new EngineConfig( );
> config.setEngineHome(" d:/eclipse/plugins/org.eclipse.birt.report.viewer_1.0.0/birt /WEB-INF "
> );
> ReportEngine engine = new ReportEngine( config );
> IReportRunnable report = null;
> try
> {
> report = engine.openReportDesign( file );
> }
> catch ( EngineException e ) //Fehler auffangen
> {
> error=( "Report " + file + " not found!\n" );
> engine.destroy( );
> return error;
> }
>
> //Here starts the part to get the parameter infos
> IGetParameterDefinitionTask task =
> engine.createGetParameterDefinitionTask( report );
> Collection params = task.getParameterDefns( true );
> if ( params.isEmpty() )
> {
> output=output+( "This report has no parameters.\n" );
> }
> Iterator iter = params.iterator( );
> while ( iter.hasNext( ) )
> {
> IParameterDefnBase defn = (IParameterDefnBase) iter.next( );
> IScalarParameterDefn param = (IScalarParameterDefn) defn;
> output=output+ "<br>Parameter: " + param.getName( );
> output=output+ "<br>Display Name: " + param.getDisplayName( ) ;
> output=output+ "<br>Type: " + param.getDataType( ) ;
> output=output+ "<br>Default Value: ";
>
> // The default value is an expression. Evaluate it.
> // Maybe here is an error?
>
> Object value = task.getDefaultValue( param );
> if (value == null)
> {
> value = "none";
> }
> else
> {
> value=value.toString( );
> }
> output=output+value;
> }
> ---------------------
> And ich get the following output:
>
> Parameter: Kunden
> Display Name: null
> Type: 1
> Default Value: none <---- SHOULD NOT BE 'none'!
>
> Parameter: Country
> Display Name: Land
> Type: 1
> Default Value: none <---- SHOULD NOT BE 'none'!
> ----------------------
>
> I hope someone could help me. Thanks in advance.
>
> Robert
Re: Own Birt Viewer, Read Param Default [message #67437 is a reply to message #67375] Thu, 11 August 2005 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Parameter's default value stored in design is treated as expression. So
you have to call that evaluation method before getting the value.

Jun Zhai
Re: Own Birt Viewer, Read Param Default [message #67661 is a reply to message #67375] Fri, 12 August 2005 03:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ksc_puschkin.yahoo.de

Thanks a lot. Worked fine :)

Robert
Get Param 4rm web page [message #68592 is a reply to message #67661] Fri, 19 August 2005 23:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sam.xxx.com

Any one know how to get the parameters from the webpage and create a
report with them ?

Iam looking for the code to create a report in Birt. our application uses
servlets , JSP.

Why do we use report Engine ? and report engine means something like
creating a report programatically ?


please help
Re: Get Param 4rm web page [message #69266 is a reply to message #68592] Tue, 23 August 2005 13:06 Go to previous message
Eclipse UserFriend
sam

We have a Design Engine API for creating report dynamically. refer to this
location for more information.
http://www.eclipse.org/birt/index.php?page=deploy/de-api.htm l.

Jason Weathersby
BIRT PMC

"sam" <sam@xxx.com> wrote in message
news:91a7afead72a2163741cda6149bf16d3$1@www.eclipse.org...
> Any one know how to get the parameters from the webpage and create a
> report with them ?
>
> Iam looking for the code to create a report in Birt. our application uses
> servlets , JSP.
>
> Why do we use report Engine ? and report engine means something like
> creating a report programatically ?
>
>
> please help
>
>
>
Previous Topic:Can we access charts in the code(via script)
Next Topic:Chart Size
Goto Forum:
  


Current Time: Thu May 08 06:47:53 EDT 2025

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

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

Back to the top