Skip to main content



      Home
Home » Archived » BIRT » Can any body help me in Passing Parameter Code it is not working
Can any body help me in Passing Parameter Code it is not working [message #102543] Tue, 27 December 2005 11:31
Eclipse UserFriend
Following java class i have written in that
Collection params = task.getParameterDefns( false );
statemnet is not returning any thing,so params is empty so rest code is
not working.

package com.Solectron;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;

import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler;
import org.eclipse.birt.report.engine.api.HTMLEmitterConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTa sk;
import org.eclipse.birt.report.engine.api.IParameterDefnBase;
import org.eclipse.birt.report.engine.api.IParameterGroupDefn;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IScalarParameterDefn;
import org.eclipse.birt.report.engine.api.ReportEngine;
import org.eclipse.birt.report.engine.api.ReportParameterConverter;

import javax.servlet.http.HttpServletResponse;

public class Prameter {
String name="";
IReportRunnable design;
public void getReport(HttpServletResponse response,HashMap values )
{
EngineConfig config = new EngineConfig();

config.setEngineHome("C:/Program
Files/eclipse/plugins/org.eclipse.birt.report.viewer_1.0.1/b irt ");
System.out.println("Function openReport");
HTMLEmitterConfig hc = new HTMLEmitterConfig( );
HTMLCompleteImageHandler imageHandler = new
HTMLCompleteImageHandler( );
hc.setImageHandler( imageHandler );
config.setEmitterConfiguration(
HTMLRenderOption.OUTPUT_FORMAT_HTML, hc );

ReportEngine engine = new ReportEngine(config);

name = "First_report.rptdesign";
try{
//Create engine with configuration

design = engine.openReportDesign(name);
System.out.println("Function openReportDesign invoked");


}catch (EngineException e)
{
System.err.println("Report " + name + " not found!\n");

return;
}

if ( values.isEmpty( ) )
return;

IGetParameterDefinitionTask task =
engine.createGetParameterDefinitionTask( design );
System.out.println("default value"+task.getParameterDefn("rptuda_3"));
Collection params = task.getParameterDefns( false );
System.out.println("Collection Interface is Empty"+params.isEmpty());

Iterator iter = values.keySet( ).iterator( );
while ( iter.hasNext( ) )
{
// name is getting value that we have passed through the JSP page.
String name = (String) iter.next( );
System.out.println("Name of iter"+name);
IScalarParameterDefn found = null;
Iterator i2 = params.iterator( );

while ( i2.hasNext( ) )
{
System.out.println("In The Next Itteraion");
IParameterDefnBase param = (IParameterDefnBase) i2.next( );
System.out.println("Param value "+param);
if ( param instanceof IParameterGroupDefn )
continue;
if ( param.getName( ).equals( name ) )
{
found = (IScalarParameterDefn) param;
break;
}
}

System.out.println("Found value"+found);
if ( found == null )
{
System.err.println( "Parameter " + name + " not found in the
report." );
continue;
}
String value = (String) values.get( name );

System.out.println("value variables values"+value);
ReportParameterConverter cfgConverter = new
ReportParameterConverter( "", Locale.getDefault( ) );
Object obj = cfgConverter.parse( value, found.getDataType( ) );
values.put( name, obj );
}
try
{

String format= HTMLRenderOption.OUTPUT_FORMAT_HTML;
IRunAndRenderTask task1 = engine.createRunAndRenderTask( design );
HTMLRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( format );
String output = name.replaceFirst( ".rptdesign", "." + format );
//options.setOutputFileName( output );
options.setOutputStream(response.getOutputStream());
task1.setRenderOption( options );


task1.run( );
System.out.println( "Created Report " + output + ".\n" );
}
catch ( Exception e1 )
{
System.err.println( "Report " + name + " run failed.\n" );
System.err.println( e1.toString( ) );
}


}


}
Previous Topic:Resize the report in preview mode ?
Next Topic:Need a code to pass parameter to report
Goto Forum:
  


Current Time: Sat May 03 03:48:13 EDT 2025

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

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

Back to the top