PHP and JavaBridge - run report and show print and export buttons [message #717220] |
Fri, 19 August 2011 15:53 |
PTPro Messages: 9 Registered: August 2011 |
Junior Member |
|
|
Hi all,
I have a web page made in PHP and I've installed tomcat with birt viewer and also installed JavaBridge.
I'm able to view my report in the PHP page if I call it using the Birt Viewer:
<?php
$dest = "http://localhost:8080/birt-viewer/frameset?__report=MyReport.rptdesign";
echo "<script language=\"javascript\">window.open('".$dest."');</script>";
?>
And this works perfectly, shows the report with all options (print, export...). However, I want to consume the report using JavaBridge and not the Birt Viewer.
I'm currently doing this:
<?php
if (!(get_cfg_var('java.web_inf_dir'))) {
define ("JAVA_HOSTS", "127.0.0.1:8081");
define ("JAVA_SERVLET", "../../tomcat/webapps/JavaBridge/JavaBridge.phpjavabridge");
}
$pth = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
$path_parts = pathinfo($pth);
$imageURLPrefix = $path_parts['dirname'] ."/images/";
require_once("../../tomcat/webapps/JavaBridge/java/Java.inc");
session_start();
$here = getcwd();
$ctx = java_context()->getServletContext();
$birtReportEngine = java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx);
java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook());
try{
$report = $birtReportEngine->openReportDesign("${here}/TopNPercent.rptdesign");
$task = $birtReportEngine->createRunAndRenderTask($report);
$task->setParameterValue("Top Count", new java("java.lang.Integer", 6));
$taskOptions = new java("org.eclipse.birt.report.engine.api.HTMLRenderOption");
$outputStream = new java("java.io.ByteArrayOutputStream");
$taskOptions->setOutputStream($outputStream);
$taskOptions->setOutputFormat("html");
$ih = new java( "org.eclipse.birt.report.engine.api.HTMLServerImageHandler");
$taskOptions->setImageHandler($ih);
$taskOptions->setEnableAgentStyleEngine(true);
$taskOptions->setBaseImageURL($imageURLPrefix . session_id());
$taskOptions->setImageDirectory($here . "/images/" . session_id());
$task->setRenderOption( $taskOptions );
$task->run();
$task->close();
} catch (JavaException $e) {
echo $e; //"Error Calling BIRT";
}
echo $outputStream;
?>
This displays the report correctly, but does not display the print and export buttons. Is there any way to call the report using JavaBridge and showing the buttons or do I really have to make this using the Birt Viewer?
Thank you for your help!
|
|
|
Re: PHP and JavaBridge - run report and show print and export buttons [message #717243 is a reply to message #717220] |
Fri, 19 August 2011 16:52 |
|
The viewer is built using AJAX and JSP fragments and is not currently in
the Report Engine API, so if you need those things then you will either
have to recreate them or use the existing viewer.
Jason
On 8/19/2011 11:53 AM, PTPro wrote:
> Hi all,
>
> I have a web page made in PHP and I've installed tomcat with birt viewer
> and also installed JavaBridge.
>
> I'm able to view my report in the PHP page if I call it using the Birt
> Viewer:
>
>
> <?php $dest =
> "http://localhost:8080/birt-viewer/frameset?__report=MyReport.rptdesign";
>
> echo "<script language=\"javascript\">window.open('".$dest."');</script>";
>
> ?>
>
>
> And this works perfectly, shows the report with all options (print,
> export...). However, I want to consume the report using JavaBridge and
> not the Birt Viewer.
> I'm currently doing this:
>
>
> <?php
>
> if (!(get_cfg_var('java.web_inf_dir'))) {
> define ("JAVA_HOSTS", "127.0.0.1:8081");
> define ("JAVA_SERVLET",
> "../../tomcat/webapps/JavaBridge/JavaBridge.phpjavabridge");
> }
>
> $pth = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
> $path_parts = pathinfo($pth);
> $imageURLPrefix = $path_parts['dirname'] ."/images/";
> require_once("../../tomcat/webapps/JavaBridge/java/Java.inc");
>
> session_start();
> $here = getcwd();
>
>
> $ctx = java_context()->getServletContext();
> $birtReportEngine =
> java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx);
> java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook());
>
>
> try{
>
>
> $report =
> $birtReportEngine->openReportDesign("${here}/TopNPercent.rptdesign");
> $task = $birtReportEngine->createRunAndRenderTask($report);
> $task->setParameterValue("Top Count", new java("java.lang.Integer", 6));
>
> $taskOptions = new
> java("org.eclipse.birt.report.engine.api.HTMLRenderOption");
> $outputStream = new java("java.io.ByteArrayOutputStream");
> $taskOptions->setOutputStream($outputStream);
> $taskOptions->setOutputFormat("html");
> $ih = new java(
> "org.eclipse.birt.report.engine.api.HTMLServerImageHandler");
> $taskOptions->setImageHandler($ih);
> $taskOptions->setEnableAgentStyleEngine(true);
> $taskOptions->setBaseImageURL($imageURLPrefix . session_id());
> $taskOptions->setImageDirectory($here . "/images/" . session_id());
>
> $task->setRenderOption( $taskOptions );
> $task->run();
> $task->close();
>
> } catch (JavaException $e) {
> echo $e; //"Error Calling BIRT";
>
> }
>
> echo $outputStream;
>
> ?>
>
>
>
> This displays the report correctly, but does not display the print and
> export buttons. Is there any way to call the report using JavaBridge and
> showing the buttons or do I really have to make this using the Birt Viewer?
>
> Thank you for your help!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03872 seconds