问题描述
本地我有一个 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 )
- 更新:工作正常:请参阅下面的答案
- 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的修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!