本文介绍了如何在服务器上获取某些子报表的ReportDesign类以进行基于scriptlet的修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本地我有一个 master.jrxml 报告和一些 subreport.jrxml ,可以加载和操作子报告 Scriptlet代码中的ReportDesign design = JRXmlLoader.load(/ local-file-dir/path/to/subreport.jrxml)

Locally I have a master.jrxml report and some subreport.jrxml and can load and manipulate the subreport via ReportDesign design = JRXmlLoader.load( "/local-file-dir/path/to/subreport.jrxml" ) in the Scriptlet code.

在服务器上,上面的加载方法(由我的 master.jrxml 触发)显然无法处理回购路径,无论我做了什么(基本上 net.sf.jasperreports.engine.JRException:java.io.FileNotFoundException:...

On the server, the above load method (trigged by my master.jrxml) obviously cannot deal with repo paths, no matter what I tried (basically net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: ...)

subreport.jrxml 作为 JRXML文件资源上传 - 而非报告,具有无形创建的文件夹结构;
subreport-attached.jrxml 作为 master.jrxml的文件资源上传报告

(subreport.jrxml uploaded as a JRXML File Resource - not as Report with invisibly created folder structures ;subreport-attached.jrxml uploaded as a file resource of my master.jrxml Report)


  • apwop)没有协议前缀的绝对回购路径,例如 /repo/path/subreport.jrxml

  • apwp)具有协议前缀的绝对回购路径,例如 repo:/repo/path/subreport.jrxml

  • rpwop)没有协议前缀的相对repo路径,例如 subreport-attached.jrxml

  • rpwp)具有协议前缀的相对repo路径,例如 repo:subreport-attached.jrxml

  • apwop) absolute repo path without protocol prefix, e.g. /repo/path/subreport.jrxml
  • apwp) absolute repo path with protocol prefix, e.g. repo:/repo/path/subreport.jrxml
  • rpwop) relative repo path without protocol prefix, e.g. subreport-attached.jrxml
  • rpwp) relative repo path with protocol prefix, e.g. repo:subreport-attached.jrxml

我还试过以下内容在网络其他地方找到的uri变种没有成功

I also tried the following with the above uri variants as found elsewhere in the web without success:


  • JRXmlLoader

JRXmlLoader.load(
  new DefaultRepositoryService( 
    DefaultJasperReportsContext.getInstance() 
  ).getInputStream( subrepPath )


  • RepositoryUtil

    RepositoryUtil.getInstance( 
      DefaultJasperReportsContext.getInstance() 
    ).getInputStreamFromLocation( subrepPath )
    


  • JasperServerUtil :类似于我还在尝试并将报告回来(直到现在有适当的Maven jasperserver库支持的问题 - 我可以在)


    • 更新:工作正常:请参阅下面的答案

    • JasperServerUtil: similar to this I am still trying out and will report back (had problems with proper Maven jasperserver libraries support till now - other problem I may address in another question)
      • update: it worked: see my answer below
      • 推荐答案

        哇! :)使用 com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService 的最后一种方法是这样的:

        Woohoo! :) The last approach with the com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService worked like this:

        JasperDesign design = JRXmlLoader.load(
           ( (RepositoryService) StaticApplicationContext.getApplicationContext()
             .getBean( "repositoryService" ) 
           )
           .getResourceData( JasperServerUtil.getExecutionContext() , 
             "repo:/some/where/subreport.jrxml" )
           .getDataStream()
        

        Puh!hard birth。

        Puh! hard birth.

        这篇关于如何在服务器上获取某些子报表的ReportDesign类以进行基于scriptlet的修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 10-11 07:58