Issue Collection is not a Java object,using NULL instead in using php/javabridge

0

Hi ,

I am facing this issue when i am sending custom data through JRBeamDataSource Collection data integrate in php but i am facing this error

Warning: argument 'Collection' is not a Java object,using NULL instead in http://localhost:8080/JavaBridgeTemplate721/java/Java.inc on line 511

this is my php code

<?php

require_once("http://localhost:8080/JavaBridgeTemplate721/java/Java.inc");
require "collection.php";

try {

    $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader");
    $jasperDesign = $jasperxml->load(realpath("customer.jrxml"));
    $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
    $report = $compileManager->compileReport($jasperDesign);
} catch (JavaException $ex) {
    echo $ex;
}

$fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
$array1 = [['debit'=> '20.00','credit'=> '50.00'],['debit'=> '10.00','credit'=> '15.00']];
$arrayList = new java( 'java.util.ArrayList');
foreach($array1 as $key => $a){
    $collect1 = new Collection();
    $collect1->setDebit($a['debit']);
    $collect1->setCredit($a['credit']);
    $arrayList->add($collect1);
}
//$arrays = ['20.00','30.00','40.00'];
$params = new Java("java.util.HashMap");
/*
$params->put("debit", "30.00");
$params->put("credit", "3.00");
$params->put("description", "Test123Customer");
$params->put("date", "2019-07-22 06:37:09");
*/

$class = new JavaClass("java.lang.Class");
$beanCollection = new Java("net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" , $arrayList);
$params->put('DataSource', $beanCollection);
$emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource");
$jasperPrint = $fillManager->fillReport($report, $params, $emptyDataSource);
$exporter = new java("net.sf.jasperreports.engine.JRExporter");

switch ($_POST['format']) {
    case 'pdf':
        $outputPath = realpath(".")."/"."output.pdf";
        
        $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");
        $exportManager->exportReportToPdfFile($jasperPrint, $outputPath);
        break;
}
?>

 

and this is my collection class php

<?php
class Collection {

    private $debit;
    private $credit;

    public function __construct()
    {
        $this->debit = '';
        $this->credit = '';
    }
    // getter-setter
    
    public function getDebit(){
        return $this->debit;
    }
    
    public function setDebit($debit){
        $this->debit = $debit;
    }
    
    public function getCredit(){
        return $this->credit;
    }
    
    public function setCredit($credit){
        $this->credit = $credit;
    }
}

?>

thats why i am seeing reporting value is null plz help me how to resolve this issue in php using php/javabridge not java?

jazebmazher728's picture
Joined: Jun 20 2019 - 8:22am
Last seen: 1 month 2 weeks ago

1 Answer:

0

I don't think there will be many folks in this community that will know the details of the PHP Java bridge enough to answer your question.

Maybe this project would be better: https://github.com/cossou/JasperPHP

 

swood_1's picture
420
Joined: Nov 15 2012 - 10:47am
Last seen: 12 hours 6 min ago
Feedback
randomness