我正在寻找一种解决方案,如何在我的计算机上填充非本地报告,但在JasperReports服务器上。
是否有任何关于在Jasperserver上获取存储库或报告的连接的示例?
它应该是,伪代码:
Map<String,Object> jasperParameter = new HashMap<String,Object>();
String linkToMyRepository="localhost:8080/jasperserver/repository"
RepositoryService service = new RepositoryService("linkToMyRepository");
JasperReport report = (JasperReport)service.getResource("myreport");
JasperFillManager.fillReport(report, jasperParameter, con);
这只是伪代码,有人可以帮帮我吗?
非常感谢!
答案 0 :(得分:4)
解决!
JServer server = new JServer();
server.setUrl("http://localhost:8080/jasperserver/services/repository");
server.setUsername("username");
server.setPassword("password");
WSClient client = new WSClient(server);
ResourceDescriptor resourceDescriptor = new ResourceDescriptor();
resourceDescriptor.setUriString ("/reports/myreportname");
Map<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("MY_PARAMETER_NAME", "myparametervalue");
JasperPrint printer = client.runReport(resourceDescriptor, parameterMap);
JasperViewer.viewReport(printer, false, Locale.GERMAN);