| Own Birt Viewer, Read Param Default [message #66745] | 
Thu, 11 August 2005 05:40   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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  
<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
 |  
 |  
  | 
 | 
 | 
 | 
 | 
 | 
Powered by 
FUDForum. Page generated in 0.05484 seconds