2016-12-05 10 views
0

私は次の質問JasperReports fillReport too slow and resource consumingを確認していましたが、確認済みの回答を適用しようとしましたが、レポートの生成に変更が見られませんでした。ジャスパーレポート - xpath executerファクトリを変更する方法

私が何をしようとしているBasicalyがJasperFillManagerではなくXalanののにJaxenを使用するためのXPath実行部の工場を変更することですが、私は私のコードで

DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance(); 
    JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory", 
                 "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory"); 
を次の行を置く場所を知っているように見えることはできません私は何か他のものは何も変化に「net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory」を変更しても

private JasperPrint getJasperPrintInstance(JasperReport report) throws JRException, NamingException, SQLException { 
    JasperPrint jasperPrint = null; 
    DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance(); 
    JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory", 
                 "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory"); 
    if (dataSource == null) { 
     jasperPrint = JasperFillManager.fillReport(report, this.reportParams, connection); 
    } else { 
     jasperPrint = 
      JasperFillManager.fillReport(report, this.reportParams, 
             new JRBeanCollectionDataSource(getDataSource())); 
    } 

    return jasperPrint; 
} 

は、次のように

私のコードブロックが見えます。

私が間違っていることを教えていただけますか?

答えて

1

これは、新しく作成されたcontextを使用していないために発生します。あなたはそれでJasperFillManagerインスタンスを作成する必要があります。

JasperFillManager jasperFillManager = JasperFillManager.getInstance(context);

をし、使用している代わりに、そのようなクラスのもののそのインスタンスメソッドを持つ:

jasperPrint = jasperFillManager.fill(report, this.reportParams, connection);

関連する問題